R9 Web Push in decePub: one subscription per persona, each with its own token and registration
Build / Build (push) Successful in 56s

Settings gets "Notifications on this device" (PushEditor): personas, alerts in four groups, policy, a test
notification, after a one-time notice of what the push service learns. Each persona ticked gets its own service
worker registration (push-worker.js at push/{slot}/), so its own endpoint and keys, subscribed with its own token
(IHttpService's *As); nothing PrivaPub stores ties two personas together and the worker never reads the payload's
token. PushService follows the tokens (re-subscribing after a renewal), reconciles at every session start, turns
off before sign-out and drops deleted or suspended personas. A click opens that persona's notifications; the app
badge counts the unread ones. Exchanges now ask for the push scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-18 09:50:46 +02:00
1 parent d33697e3fc
commit ab17959ed4
29 files changed
+2047 -67

No files matched your search

+28 -2
View File
@@ -49,9 +49,13 @@ window.isOnline = async () => {
window.logFromJs(e.message, "isOnline")
}
}
// The installed app's badge: the current persona's unread notifications (Index.razor). Browsers without the Badging API
// (Firefox, or a tab that isn't installed) show none, and say nothing about it.
window.setAppBadge = (counter) => {
try {
navigator.setAppBadge(counter)
if (typeof navigator.setAppBadge != "function")
return
navigator.setAppBadge(counter)?.catch?.(e => console.debug(e))
} catch (e) {
console.error(e)
window.logFromJs(e.message, "setAppBadge")
@@ -59,12 +63,34 @@ window.setAppBadge = (counter) => {
}
window.clearAppBadge = () => {
try {
navigator.clearAppBadge()
if (typeof navigator.clearAppBadge != "function")
return
navigator.clearAppBadge()?.catch?.(e => console.debug(e))
} catch (e) {
console.error(e)
window.logFromJs(e.message, "clearAppBadge")
}
}
// A click on a Web Push notification while decePub is open: the persona's worker (push-worker.js) focuses this tab and
// says which of its registrations showed it, and the app opens that persona's notifications (CascadingState.PushOpened).
// Only this origin's workers can post here.
try {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.addEventListener("message", event => {
try {
if (event.data?.type !== "decepub-push-open" || typeof event.data.slot != "string")
return
window.cascadingStateInstance?.invokeMethodAsync("PushOpened", event.data.slot)
} catch (e) {
console.error(e)
window.logFromJs(e.message, "pushOpened")
}
})
navigator.serviceWorker.startMessages()
}
} catch (e) {
console.error(e)
}
// On a touch screen a tap on a post (not on its links, controls or menus, and not ending a text selection) opens its
// thread, through the card's own thread link (Content.razor, data-thread-link), which Blazor's router takes.
document.addEventListener("click", event => {