snapshot-labs / snapshot-webhook

Snapshot notification service.
MIT License
10 stars 15 forks source link

Make browser notifications works for all space #23

Open bonustrack opened 2 years ago

bonustrack commented 2 years ago

Instead of having to subscribe for space one by one, we should change the browser notification system so you get notified for all space you follow. First step is to do specs on how to do that change.

bonustrack commented 2 years ago

We need first to make it possible on the UI to enable or disable browser notifications

samuveth commented 2 years ago

I've added a design task for concepted for the toggle inside the notifications dropdown.

Next step will be figuring out the mechanic for subscribing to all spaces and automatically subscribing when new spaces are followed.

bonustrack commented 2 years ago

This is the current implementation:

In the frontend: https://github.com/snapshot-labs/snapshot/blob/develop/src/composables/useSpaceSubscription.ts#L65-L66 The function that send notifications: https://github.com/snapshot-labs/snapshot-webhook/blob/master/src/helpers/beams.ts

Currently we use Pusher.com "Beam" solution to manage notifications, with Beam you can create a "topic" and send notifications for everyone who subscribed to that topic, the issue with topic is that an user can only subscribe to a topic by doing a request in our frontend, we can't subscribe an user to different topics without the user. If an user join the space Uniswap with his desktop browser we can subscribe him to the space notification and use the space id "uniswap" as topic, but if user leave a space with his mobile phone we are not able to unsubscribe him to "uniswap" notifications cuz device changed. This is the reason that we've been using wallet address as topic in our current implementation, this allow us to send notifications to the users when we know an event for a space they subscribed to occur. But topic shouldn't be used for that, there is a limit of 100 topic event you can publish in a request see https://github.com/snapshot-labs/snapshot-webhook/blob/master/src/helpers/beams.ts#L32 this doesn't scale

I would recommend check again if there is a way we can make it work with Pusher, otherwise we can explore https://firebase.google.com , this solution might help too: https://novu.co/

bonustrack commented 2 years ago

WIP by @eswarasai

zzuziak commented 1 year ago

Hey @eswarasai, what's the status on this issue?