iOS: the player goes to ipxapi.sdf1.net with one API token; unread badge (#419, #421)

The Access service token plus API token pair was three values to enter
and Access in front of both. The player, the badge and CarPlay now send
the ipx API token alone to https://ipxapi.sdf1.net: a route of the
rays-unraid tunnel to the same ipx-web, with no Access application, held
to the paths the app uses by a custom firewall rule on the sdf1.net zone
(403 for anything without a bearer header or off the list: the page, the
login form, /api/login, ?token= sign-in, the admin API). docs/sso.md
says so, since it also says not to bypass Access for /api/*; this is
that warning's narrow version, and the rule is on Cloudflare, not here.

The unread badge (#421) shows All Subscriptions' count, as the page's
badge does: set when the app comes forward, after an item is read, and
by a background refresh iOS runs now and then. The test target had no
Info.plist and could never have run; it does now.

Build 4. Not yet run on a phone with the token set.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Ray Slakinski
2026-11-08 14:11:03 -05:00
parent 7d4456bb2f
commit 3626a30b52
14 changed files with 234 additions and 64 deletions

View File

@@ -95,7 +95,7 @@ final class Playback: NSObject {
// second has something to do about it.
let msg = pi.error?.localizedDescription ?? "the file could not be played"
let status = await self.request("GET", "/api/me")
let expired = Credentials.isSet ? "Check the tokens in Settings" : "Sign in again"
let expired = Credentials.isSet ? "Check the player token in Settings" : "Sign in again"
self.onError?(status == 401 || status == 403 ? expired : msg)
default: break
}
@@ -204,7 +204,10 @@ final class Playback: NSObject {
private func markRead() {
guard !markedRead, let item else { return }
markedRead = true
Task { await request("POST", entryPath(item, "flags"), ["read": true]) }
Task {
await request("POST", entryPath(item, "flags"), ["read": true])
await Badge.refresh()
}
}
// MARK: - the lock screen and the car
@@ -256,7 +259,7 @@ final class Playback: NSObject {
let centre = MPNowPlayingInfoCenter.default()
centre.nowPlayingInfo = info
guard let art = item.artwork, let url = Server.resolve(art) else { return }
guard let art = item.artwork, let url = Server.resolveForPlayer(art) else { return }
Task {
var artReq = URLRequest(url: url)
Credentials.headers.forEach { artReq.setValue($1, forHTTPHeaderField: $0) }
@@ -295,7 +298,7 @@ final class Playback: NSObject {
/// arrived. A position that does not save is saved again ten seconds on.
@discardableResult
private func request(_ method: String, _ path: String, _ json: [String: Any]? = nil) async -> Int? {
guard let url = Server.resolve(path) else { return nil }
guard let url = Server.resolveForPlayer(path) else { return nil }
var req = URLRequest(url: url)
req.httpMethod = method
Credentials.headers.forEach { req.setValue($1, forHTTPHeaderField: $0) }