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
@@ -214,6 +214,25 @@ struct MicropubTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func `a 5xx names micro.blog's outage not a bare status`() {
|
||||
// Their errors arrive as HTML pages, so the JSON decode finds
|
||||
// nothing — a 503 over that body names their side; a 4xx keeps
|
||||
// the bare status; a described 5xx keeps the description.
|
||||
let html = Data("<html><body>503 Service Unavailable</body></html>".utf8)
|
||||
let outage = Micropub.decodeFailure(status: 503, body: html)
|
||||
guard case let .requestFailed(status, detail) = outage else {
|
||||
Issue.record("expected requestFailed, got \(outage)")
|
||||
return
|
||||
}
|
||||
#expect(status == 503)
|
||||
#expect(detail.contains("their side"))
|
||||
|
||||
let bare = Micropub.decodeFailure(status: 422, body: html)
|
||||
#expect(bare == .requestFailed(status: 422, detail: "HTTP 422"))
|
||||
let described = Micropub.decodeFailure(status: 502, body: Data(#"{"error_description":"upstream timeout"}"#.utf8))
|
||||
#expect(described == .requestFailed(status: 502, detail: "upstream timeout"))
|
||||
}
|
||||
|
||||
@Test func `publish outcome is published on 2xx`() async {
|
||||
let log = MicropubRequestLog()
|
||||
let outcome = await Micropub.publish(
|
||||
|
||||
Reference in new issue
Block a user