Repository navigation
Optional Pushover delivery for watched-node alerts - #2455
Conversation
13c7062 to
97cb9eb
Compare
With notifications.pushover.subscriptionCode set, the account page offers Connect Pushover: CoreScope sends the browser to the pushover.net subscription page and saves the key Pushover returns. Pasting a user key stays as the fallback. The return link carries a one-time token tied to the user who started, valid for 15 minutes, and the return needs that user's session, so a crafted link can't put another key on someone's account. A return with pushover_unsubscribed removes the saved key. The account page reports how the round trip went.
Unsubscribing in the Pushover app makes Pushover reject the key, and CoreScope then turns Pushover off for that user. Say so, and how to connect again.
|
Review of Two points before merge:
Smaller notes, none blocking:
Not checked: a live pushover.net round trip (the screenshot placeholder in the description is empty), |
- notification_pushover_sent gets user_id (in v12). A user's message is queued only while their sends in 24 hours plus their queued messages stay under notifications.perUserPerDay; the test endpoint answers 429 past it. A deleted user's sends still count toward the instance cap. - The account export carries keyHint (last 4 characters), not the key. - dispatch sends at most the cap's remaining room, even within a batch. An empty queue costs one indexed SELECT: the cap is counted only when messages are due, and expired messages are pruned once a minute. - A 4xx whose body isn't Pushover's JSON is retried like a 5xx and never turns a key off. - Connect Pushover: the rate limit is checked before the one-time token is used, so a busy return can be retried with the same link. A signed-out return goes to the login page, which reports it. - Named struct for the subscribe answer; openapi lists subscribe? and the new 429; config.example.json shows a pushover block (inactive under _pushover); the docs cover the limit, the export and the plain-text key in users.db backups.
|
Review feedback addressed (commit Before merge:
Smaller notes:
Ran: gofmt and |
Brings in Kpa-clawbot#2457, Kpa-clawbot#2490, Kpa-clawbot#2488, Kpa-clawbot#2500 and Kpa-clawbot#2455. Conflicts were two added lines on each side: the eslint globals (frameHex/frameSize and NeighborRank) and the deploy.yml E2E suite list (the privacy-on suite and test-neighbor-rank-e2e.js); both kept. The leak test now requests Kpa-clawbot#2457's /api/nodes/neighbor-rank, which serves no positions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Pushover to Postgres Brings in 37 master commits, including the push relay (Kpa-clawbot#2447), Pushover (Kpa-clawbot#2455), plain SMTP (Kpa-clawbot#2466), neighbour rank (Kpa-clawbot#2457), the observers rebuild fix (Kpa-clawbot#2445) and Kpa-clawbot#2486. Conflicts: config.example.json, docs/api-spec.md and auth_service.go keep both sides (as n30nex's merge notes say); dbschema's observers check keeps the Postgres branch in front of Kpa-clawbot#2445's rowid-alias check; the release-routing test keeps musl-test; CHANGELOG keeps only unreleased entries; notify_service.go keeps master's destinations plus the cluster lock on evaluation, and the email claim moves to notifyChanges.claim. users.db schema: master's v11 (push relay) and v12 (Pushover) come first, this branch's rate_limits becomes v13, and v14 adds push_relay_state, push_relay_pending and notification_pushover_subscriptions. Push relay and Pushover on Postgres with several server replicas: - Postgres migrations v11-v14 with the five SQLite triggers as plpgsql; instr -> strpos, typed VALUES, a qualified ON CONFLICT WHERE, integer booleans. The parity test also compares trigger names. - Relay enrollment, delivery phase and the pending enrollment (with the Ed25519 proof seed) move from <users.db>.push-relay*.json and process memory into the accounts store. Writes are compare-and-set on a revision; replicas reload it per tick, per dispatch pass and per job. Old files are imported once, except an enrollment under a manual relay or for another public origin, which is left on disk and never prunes. - Credentials and the seed are sealed with userManagement.encryptionKey (CORESCOPE_ACCOUNTS_KEY), required on Postgres; on SQLite without a key they are stored as before, inside users.db. Leftover plain values are re-sealed at startup once a key is set. users.db is set to 0600, and user backups blank the relay secrets. - Queue rows are claimed with a 5-minute lease (SKIP LOCKED on Postgres); each queue drains under a cluster lock; advisory locks use their own connection pool, so lock holders cannot starve the accounts store. Device links and the Pushover per-user limit lock the user. - The enrollment proof and the Pushover connect token work on any replica; the proof endpoint validates before any database read and is limited per IP; device link/unlink are limited per user. Also fixed while integrating: - node_reach used IS NOT 'tx', which Postgres rejects (from Kpa-clawbot#2486). - docker/server-exec.sh did not pass five variables the server reads (CORESCOPE_ACCOUNTS_KEY, CORESCOPE_PUSHOVER_TOKEN, CORESCOPE_PUSH_RELAY_CREDENTIAL, CORESCOPE_SMTP_PASSWORD, CORESCOPE_URL); tests/unit/test-server-exec-env.js now checks the list. - corescope-migrate copy-users/verify-users failed on notification_pushover_sent (no key); it gets a rowid on Postgres, like mail_events, and verify redacts credential and seed columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Adds Pushover as an optional destination for watched-node alerts, next to email and the push relay from #2447. An admin enables it with a Pushover application token; each user then connects their own Pushover account from My account → Notifications and gets the same alerts as email in the Pushover app. CoreScope sends to Pushover directly; no relay is involved.
It plugs into the
notifyDestinationinterface from #2447 (now merged). The changes are four commits:eca5b21cstore and server: the per-user destination behind the notifier interfacec12539c2account page section, docs, OpenAPI and export test6992fe4aConnect Pushover through a Pushover subscription41bbfefddocs: stopping Pushover from the Pushover appSetup (admin)
CORESCOPE_PUSHOVER_TOKENin the server environment. The token never goes inconfig.json.userManagement.notifications:subscriptionCodeis optional. It comes from a web-based subscription in the application's settings on pushover.net, whose base URL must be the analyzer'spublicBaseUrl. Without it, users paste their user key instead of using Connect Pushover. CoreScope refuses to start with the block but without a valid token.Behavior
users.db. Messages are queued in the same transaction as the notification state change and sent by a worker every 5 seconds. Failures are retried with backoff (honoring Pushover'sRetry-After) for up to an hour, then dropped. If Pushover rejects a user's key, Pushover is turned off for that user. Changing or removing the key, or turning Pushover off, drops that user's queued messages.maxPerMonth(default 7,500) caps the messages sent in a rolling 30 days, test messages included, below Pushover's free tier of 10,000 per application per month. Messages queued after the cap is reached expire unsent.users/validateendpoint before it is saved. Key checks (saving a key, or the return from Connect Pushover) and Send test share a limit of 10 per hour per user. Each user has at most one Connect Pushover in progress; starting another replaces it.Connect Pushover
With
subscriptionCodeset, the account page shows Connect Pushover. It sends the browser to the pushover.net subscription page and saves the application-specific key Pushover returns.pushover_unsubscribedremoves the saved key if it matches.Cache-Control: no-storeandReferrer-Policy: no-referrer.Changes
internal/users: users.db v12 withnotification_pushover,notification_pushover_jobsandnotification_pushover_sent. Triggers drop queued jobs when the key changes or Pushover is turned off. Jobs are queued fromApplyNotifyChangesthroughNotifyOutbox.PushoverMessages.cmd/server:pushoverDestinationimplementsnotifyDestination, alongside email and the push relay.PUT/DELETE /api/account/notifications/pushover,POST .../pushover/test, and, with a subscription code,POST .../pushover/subscribe,GET .../pushover/subscribed/{token}andGET .../pushover/subscribe-failed.GET /api/account/notificationsgains apushoverobject while the instance offers Pushover.public/notifications.js: the Pushover part of the Notifications section.docs/user-guide/accounts.md: setup and behavior.No changes to the analyzer DB, the ingestor or the read/write separation: everything lives in
users.dbthroughinternal/users.Testing
make test: all modules pass.go test -racepasses on the server notification, push, destination, export and OpenAPI tests.internal/userscover the key lifecycle, queueing only for active users, expiry, and send counting.test-all.shand eslint pass.tests/unit/test-notifications-ui.jshas 20 tests, including Connect Pushover and the outcome messages.