Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NV-1759] fix(api): fixed remove subscriber from topic functionality #2903

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

LetItRock
Copy link
Contributor

What change does this PR introduce?

Fixes the issue: #2902

When the subscriber is added to multiple topics the POST /topics/:topic_key/subscribers/removal endpoint removes him from all the topics, but should only remove from the exact topic by the :topic_key.

Why was this change needed?

Fixes the above issue.

Other information (Screenshots)

Screenshot 2023-02-24 at 22 34 46

Screenshot 2023-02-24 at 22 35 05

Screenshot 2023-02-24 at 22 34 58

@@ -135,4 +135,90 @@ describe('Remove subscribers to topic - /topics/:topicKey/subscribers/removal (P
expect(getResponseTopic.name).to.eql(topicName);
expect(getResponseTopic.subscribers).to.eql([]);
});

it('should remove subscriber from only one topic', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests to cover the issue

@@ -42,7 +42,7 @@ export class TopicSubscribersRepository extends BaseRepository<EnforceEnvironmen
await this.delete({
_environmentId,
_organizationId,
key: topicKey,
topicKey,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue :D

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@LetItRock LetItRock changed the title fix(api): fixed remove subscriber from topic functionality [NV-1759] fix(api): fixed remove subscriber from topic functionality Feb 24, 2023
@linear
Copy link

linear bot commented Feb 24, 2023

NV-1759 🐛 Bug Report: Removing a subscriber from a topic removes them from all subscribed topics

📜 Description

If a user is subscribed to a bunch of topics and we remove them from a single topic using https://api.novu.co/v1/topics/:topicKey/subscribers/removal then the subscriber is actually removed from all topics rather than just the defined topic.

👟 Reproduction steps

  1. Add a subscriber to multiple topics.
  2. Call https://api.novu.co/v1/topics/:topicKey/subscribers/removal with a single topic
  3. Check the topics that are subscribed and you'll see the subscriber is no longer subscribed.

👍 Expected behavior

Removing should only remove the subscriber from the defined topic.

👎 Actual Behavior with Screenshots

Subscriber is removed from every topic they're subscribed to.

📃 Provide any additional context for the Bug.

Discord: https://ptb.discord.com/channels/895029566685462578/1078569121861603389

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Copy link
Contributor

@p-fernandez p-fernandez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌟

@@ -42,7 +42,7 @@ export class TopicSubscribersRepository extends BaseRepository<EnforceEnvironmen
await this.delete({
_environmentId,
_organizationId,
key: topicKey,
topicKey,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

@p-fernandez p-fernandez added this pull request to the merge queue Feb 25, 2023
Merged via the queue into next with commit e58b32a Feb 25, 2023
@p-fernandez p-fernandez deleted the fix-remove-subscriber-from-topic branch February 25, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants