feat(server): send notifications and back up the database

Merged
BR
12d ago
+2637-3

Summary

Closes #10. Part of #1.

  • Adds notifications through two channels, an ntfy topic and a generic webhook, each set up and tested from Settings. A saved channel is shown without its topic, token or the secret parts of its URL.
  • Four events, each with its own switch: posted, failed (a post that failed for good, or one left needing a check), token about to expire (once a day while it expires within 7 days or is refused), and pool running low (once each time it drops below the threshold).
  • A notice never carries coordinates, a file name, a caption or a link. Sending is in the background with a timeout and two retries, follows no redirect, and never fails a post; each channel's last error shows in Settings.
  • In fake mode nothing is sent: each notice is recorded as "would have been sent", and Send test says so.
  • The database is copied nightly into backups/ in the data folder with VACUUM INTO, so a copy is consistent while the app runs. Copies are owner-only, named by date, and seven are kept. A copy is also made at start when the last is more than a day old.
  • The README documents restoring from a copy.
  • No new dependencies and no migration. Decisions are recorded as ADR 0009.

Evidence

From a scratch install in fake mode.

Settings with the notification channels, event switches, latest notices and the backups line

Typecheck, lint, 577 tests and the build pass locally. In fake mode the first backup was made at start, opened as a valid database, and was readable by its owner only; a fake post produced a "would have been sent" notice with no file name or coordinates, and a saved webhook was shown without its path or key.

Merge Danger

Low. Notifications are the server's first requests to addresses the owner types in: http and https only, no redirects, and only in live mode. Backups hold the Instagram token, as the database does.

Summary by CodeRabbit

  • New Features
    • Added notification settings for ntfy and webhooks, including event controls, pool thresholds, test notices, and recent delivery status.
    • Added automatic database backups, with backup status and schedule available in Settings.
    • Added a restore option that starts posting paused and holds in-progress posts for review.
  • Documentation
    • Added guidance on backup retention, restoring database state, and resuming posting.