Changeset e61c289 in Klonkt for src/services/PushService.js


Ignore:
Timestamp:
07/24/2026 05:03:34 PM (7 weeks ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
318d0c2
Parents:
6b5d7da
Message:

Guardian-queues als C2S-routes + push-typen help/guardian

De drie shaer:queues-collecties uit het actor-doc zijn nu echte owner-only
routes (Bearer, zelfde patroon als /blocked): offers, follows (leeg tot
gated follows bestaan) en wards. Contract gelijk aan de Shaer test-daemon,
dus de iOS/Android-dashboards lezen ze ongewijzigd.

Web-push kent twee nieuwe alert-typen: 'help' (hulpvraag van een ward,
niet gethrottled, standaard aan) en 'guardian' (adoptieverkeer). Teksten in
nl/en/de.

Changed files:
src/routes/activitypub.js

  • GET /ap/users/:slug/queues/{offers,follows,wards}, owner-only

src/services/PushService.js

  • alert-typen help + guardian (defaults aan, throttle 0/30s)

src/services/i18n.js

  • push.n_help_*, push.n_guard_* in nl/en/de

New file:
test/guardianship.test.js

  • pint het module-oppervlak: actor-props, handshake C2S+S2S beide kanten, queue-shapes, ward-mag-niet-guarden, helpRequest-props

-robo
Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/PushService.js

    r6b5d7da re61c289  
    6868// ── Subscriptions ───────────────────────────────────────────────────
    6969
    70 export const DEFAULT_ALERTS = { follow: 1, reply: 1, like: 0, boost: 0, dm: 1 };
     70// help (a ward's call for help) and guardian (adoption handshake) serve the
     71// Guardian PWA and default ON: a guardian must never miss a call for help.
     72export const DEFAULT_ALERTS = { follow: 1, reply: 1, like: 0, boost: 0, dm: 1, help: 1, guardian: 1 };
    7173
    7274export function saveSubscription({ endpoint, userId, p256dh, auth, alertTypes, uaLabel }) {
     
    122124// (the events themselves are still in Berichten — only the ping is deduped).
    123125// In-memory is fine: one process, and a restart just means one extra ping.
    124 const THROTTLE_SECONDS = { follow: 60, reply: 30, dm: 30, like: 300, boost: 300, test: 0 };
     126const THROTTLE_SECONDS = { follow: 60, reply: 30, dm: 30, like: 300, boost: 300, test: 0, help: 0, guardian: 30 };
    125127const _lastPush = new Map();
    126128export function throttled(userId, type, nowSeconds = Math.floor(Date.now() / 1000)) {
     
    135137
    136138// Notify one user on all their devices, honouring per-type preferences.
    137 // type ∈ {follow, reply, like, boost, dm, test}. Fire-and-forget at call sites.
     139// type ∈ {follow, reply, like, boost, dm, help, guardian, test}. Fire-and-forget at call sites.
    138140export async function notifyUser(userId, { type, title, body, url }) {
    139141  if (!(await pushReady())) return 0;
Note: See TracChangeset for help on using the changeset viewer.