Skip to content

Conversation

semohr
Copy link
Collaborator

@semohr semohr commented Jul 11, 2025

This PR introduces the foundational functionality for sending and receiving push notifications to registered devices. It includes everything necessary to implement basic notification flows, including sending from the backend and displaying on the client side.

This is a draft! And we still have to implement quite some things to get this working.

TODOs:

  • register new subscriptions (push + webhooks)
  • define triggers for notifications including settings
  • display notifications

Technicals

  • The system uses VAPID (Voluntary Application Server Identification) keys for secure Web Push communication per deployment.
  • Keys are automatically generated on first run if they don't exist.
  • Generated keys are stored persistently in the Beets Flask config directory, ensuring they're reused across server restarts.
  • Notifications are sent using the Web Push protocol via the pywebpush library.
  • Devices register their push subscription (endpoint + keys) with the server (placed in new sql table)
  • Service worker is transpiled and registered using vite, which allows us to display notification on the client (worker.ts)

Copy link

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

@0xC0ncord
Copy link

This would be super useful to me! But, would it be possible to also allow configuring a webhook URL for notifications on the server-side? This would allow me to instead forward notifications to e.g. a ntfy server or Discord channel.

@semohr
Copy link
Collaborator Author

semohr commented Jul 11, 2025

I'm not currently using ntfy myself, and from what I’ve seen, the standard Web Push + Notification API seems a lot more powerful, at least for enabling interactions directly within our app. In general, I lean toward supporting open standards first, since they offer the broadest compatibility. But once that’s solid, adapting it to send messages to alternative services could definitely be doable.

That said, it should be relatively straightforward to patch the server-side notification function to forward messages to additional endpoints, assuming some kind of configuration is enabled.

I won’t prioritize support for external endpoints right now, but I’ll keep it in mind, especially when considering the database representation of push subscribers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants