From 809f5304868aa2ddb8c6193c9fe4c463fb87b55f Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 03:43:12 +0800 Subject: [PATCH] fix(astrbot): try the current file API before the legacy one The server was upgraded and now routes /api/v1/files: an unknown /api/v1 path answers 404 "Not Found" where it previously answered 401, and both /api/v1/files/content and /api/v1/files/{id}/content answer 401 "Missing API key", which is a route that exists rather than a catch-all. Order the candidates accordingly. By name first, since that is what a media frame carries; by id second, because markers already written to local history hold the id from attachment_saved and can now resolve. The /api/chat pair moves last, where it still serves a server that has not been upgraded. Co-Authored-By: Claude Opus 5 --- src-tauri/src/networking/astrbot_client.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/networking/astrbot_client.rs b/src-tauri/src/networking/astrbot_client.rs index 2ff2ab9..31eca9f 100644 --- a/src-tauri/src/networking/astrbot_client.rs +++ b/src-tauri/src/networking/astrbot_client.rs @@ -492,10 +492,16 @@ impl AstrBotClient { } let encoded = urlencoding_username(attachment_id); let mut last_note = String::new(); + // Current AstrBot serves both forms under `/api/v1/files`. By name + // first, because that is what a media frame carries; by id second, + // because markers already stored in history hold the id from + // `attachment_saved`. The `/api/chat/*` pair is what older builds + // exposed, kept last so an un-upgraded server still works. for path in [ + format!("/api/v1/files/content?filename={encoded}"), + format!("/api/v1/files/{encoded}/content"), format!("/api/chat/get_file?filename={encoded}"), format!("/api/chat/get_attachment?attachment_id={encoded}"), - format!("/api/v1/files/content?filename={encoded}"), ] { match self.try_attachment(&path).await? { Ok(found) => return Ok(found),