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 <noreply@anthropic.com>
这个提交存在于:
父节点
4063215b0a
当前提交
809f530486
共有 1 个文件被更改,包括 7 次插入 和 1 次删除
|
|
@ -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),
|
||||
|
|
|
|||
正在加载…
添加表格
在新工单中引用