fix: bound site JSON response bodies

This commit is contained in:
2026-09-24 21:25:03 +08:00
parent 6a87583cc0
commit 7b4e273533
8 changed files with 87 additions and 27 deletions
+2 -5
View File
@@ -69,16 +69,13 @@ pub async fn fetch(note_id: &str) -> Result<model::Note, FetchError> {
_ => crate::site::status_error("misskey", &response),
});
}
response.json().await.map_err(|e| FetchError::Site {
site: "misskey",
error: Box::new(e),
})
crate::site::response_json(response, "misskey").await
}
/// Maps a 400 response: NO_SUCH_NOTE is permanent NotFound, any other 400 is
/// a site error (permanent — retrying a rejected request cannot succeed).
async fn not_found_or_invalid(response: reqwest::Response) -> FetchError {
match response.json::<serde_json::Value>().await {
match crate::site::response_json::<serde_json::Value>(response, "misskey").await {
Ok(v) if v["error"]["code"] == "NO_SUCH_NOTE" => FetchError::NotFound,
_ => FetchError::Site {
site: "misskey",