feat(microblog): add app token settings page and honest 5xx wording
The app token could only be entered in the publish sheet, and that field came back only after a 401/403, so a saved token had no standing way to be replaced or removed. The new Settings → Micro.blog page writes the same `MicropubTokenStore` slot the sheet reads, with a status row read back from the Keychain after every write so a locked keychain fails visibly instead of claiming "stored". The sheet now names the stored token a send carries when its field is hidden. Micro.blog's errors arrive as HTML pages, never Micropub JSON, so `decodeFailure` fell through to a bare `HTTP 503` that said nothing about whose side it was on. Any 5xx without a JSON description now reads "unavailable on their side — retry in a few minutes"; a described 5xx keeps its description and a 4xx keeps the bare status. One decode covers create, publish, q=config, and media uploads. Docs: AGENTS.md bullets, CHANGELOG [Unreleased] Added/Fixed, and the devlog for this task plus the 0.1.2 release log.
This commit is contained in:
1 parent
9aa0314564
commit
6938826101
11 files changed
+272
-14
No files matched your search
+11
-3
@@ -168,13 +168,21 @@ nonisolated enum Micropub {
|
||||
|
||||
/// Internal for MicropubMedia's media steps (#34) — the one failure
|
||||
/// decode this client speaks; extensions share it rather than fork it.
|
||||
/// A 5xx is Micro.blog's side (their nginx front with the app not
|
||||
/// answering behind it, or a rate limit) and arrives as an HTML page,
|
||||
/// never Micropub JSON — so the fallback names the outage instead of
|
||||
/// a bare `HTTP 503` (2026-12-04: a 503 in the sheet while the
|
||||
/// endpoint answered its usual 400 to a tokenless probe minutes later).
|
||||
static func decodeFailure(status: Int, body: Data) -> Outcome {
|
||||
let root = (try? JSONSerialization.jsonObject(with: body)) as? [String: Any] ?? [:]
|
||||
let detail = (root["error_description"] as? String) ?? (root["error"] as? String) ?? "HTTP \(status)"
|
||||
let described = (root["error_description"] as? String) ?? (root["error"] as? String)
|
||||
if status == 401 || status == 403 {
|
||||
return .authFailed(detail)
|
||||
return .authFailed(described ?? "HTTP \(status)")
|
||||
}
|
||||
return .requestFailed(status: status, detail: detail)
|
||||
let fallback = (500 ... 599).contains(status)
|
||||
? "unavailable on their side — retry in a few minutes (status.micro.blog)"
|
||||
: "HTTP \(status)"
|
||||
return .requestFailed(status: status, detail: described ?? fallback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user