Commit Graph
6 Commits
Author SHA1 Message Date
Juan Castro 3da39b7e35 fix(push): record device results under the owning user
Test devices register under live sessions, which delivery now requires.
2026-10-24 16:07:59 -04:00
Juan Castro dc027f9f0e fix(push): label app messages with the sending app's stamped name
Taps target the app by uid, since the stamped name is the app's title.
2026-10-24 16:07:58 -04:00
Juan Castro 4fd9fae926 feat(push): send pushes for new notifications through a registered provider
Every non-silent notification write and in-place update emits a node-local
`notif.written` event. PushService picks it up when push is enabled and a
provider is registered, and sends it to the user's devices unless the user
is connected where the notification already shows.

- `app.message` needs the user's push consent for that app and reaches
  Puter's devices plus that app's; every other type follows the user's Puter
  preference and reaches Puter's devices only.
- Presence counts this node's sockets, and other nodes and regions where
  presence is kept.
- Providers register per platform with `registerProvider`; core ships none.
  Batches of 100 tokens, bounded concurrency, no retries. Delivered devices
  are touched, unregistered ones removed, others get a failure counted.
- Messages are built per type and fit to a 3,800 byte budget; `data` is
  never cut.
2026-10-24 16:07:58 -04:00
Juan Castro a17ace4187 feat(push): device endpoints for the signed-in user
POST, GET and DELETE /push/devices on the api subdomain let a signed-in
Puter session register, list and remove its account's push devices. Apps,
access tokens and worker sessions get 403. Registration answers 503
push_disabled unless push.enabled is set; listing and removal always work.
An account keeps at most 20 devices, and a new one removes the least
recently seen. Responses never include the device token.
2026-10-24 16:03:45 -04:00
Juan Castro f089f03049 fix(push): deliver only to devices with an active session
Delivery skips devices whose session is revoked, expired or gone; devices
with no session still receive. A token that changes owner gets a new uid
and created_at, and a register that keeps losing the token to another
user ends in a 409. touch and recordFailure match the owner as well as
the uid, listByUser reads from the primary, the stale sweep stops between
batches once shutdown starts, and the user agent and label limits are
exported.
2026-10-24 16:03:35 -04:00
Juan Castro 21799137d3 feat(push): device registry with session and stale cleanup
Adds the push_device table on SQLite, MySQL and Postgres, a store for
registering, refreshing, listing and removing devices, and a push service
that removes devices when their session is revoked or when they go unseen
past push.deviceRetentionDays (default 60). Devices go with their account
through the user foreign key.
2026-10-24 16:03:35 -04:00