novuhq / novu

Open-Source Notification Platform. Embeddable Notification Center, E-mail, Push and Slack Integrations.
https://novu.co
Other
34.74k stars 3.55k forks source link

[NV-1517] πŸš€ Feature: Topic filtration #2424

Open MichalNemec opened 1 year ago

MichalNemec commented 1 year ago

πŸ”– Feature description

await novu.trigger('<REPLACE_WITH_EVENT_NAME_FROM_ADMIN_PANEL>', {
  to: [{ type: TriggerRecipientsTypeEnum.TOPIC, topicKey: topicKey }],
  payload: {
    "NOT": ["a","b"]
  },
});

based on this, the topic is now sent to all subscribed users. topic filtration rule could have some option to send topic to all EXCEPT ["a", "b"]

🎀 Why is this feature needed ?

its needed when you need to manipulate topic

✌️ How do you aim to achieve this?

Topic filtration for my usecase below. Its simple exclude which is needed for my app to do notifications correctly.

πŸ”„οΈ Additional Information

my usecase is about comments: when comment is sent, it has to be verified by owner of post.. if its verified, then i wanted the topic usecase.. dont send the notification to owner of post and send special notification to owner of comment and then send notification to all except owner of post and owner of comment (since new comment would not be clear for owner of comment and owner of post knows there is new comment, since its verified)

or another usecase: When owner of post comments on a post, it will send out notification to everyone subscribed. Owner is subscribed too to see new comments from other people. The owner should then NOT get push notification about his comment.

πŸ‘€ Have you spent some time to check if this feature request has been raised before?

🏒 Have you read the Code of Conduct?

Are you willing to submit PR?

None

From SyncLinear.com | NV-1517

NwaforAugustine321 commented 1 year ago

@MichalNemec I would love to work on it if not yet assigned for contribution.

MichalNemec commented 1 year ago

i spoke with @iampearceman but so far i dont know if its going to be implemented or not. This would be really nice, because unsubscribing those subscribers then send it and then resub again is just.. weird.

MichalNemec commented 1 year ago

just checking in: Is there another way to overcome this?

scopsy commented 1 year ago

@MichalNemec in the latest release we have added a default behaviour to filter out the actor of the notification from receiving the notification. So when triggering you can specify the actor as the owner for it to be filtered out. Unfortuently if you want to achieve it in other way we don't have a an API at the moment to filter out topic subscribers. IMO it's not very complex to implement, we just don't have enough people asked for this.

Do you want to help with this? we would need to finalize the API, since in my opinion it shouldn't be in the payload object, but we can work together to find a better place for it.

MichalNemec commented 1 year ago

@scopsy Thank you for your work! Im completely swamped right now, but whenever i have time (probably next month) ill try to do PR. I went through the code for the PR and technically if new field called "skip" or something was added, then filtration could be on array and its done.

The only thing im missing now is the flutter client hehe, but thats a different topic.