Skip to content

Commit

Permalink
fix: prevent duplicate notifications being sent (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Jan 24, 2025
1 parent 43a8800 commit c04dd09
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Jobs/SendNotificationWhenDiscussionIsReTagged.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function handle(NotificationSyncer $notifications)
->whereIn('tag_user.tag_id', $tagIds->all())
->whereIn('tag_user.subscription', ['follow', 'lurk'])
->get()
->unique()
->reject(function ($user) use ($firstPost, $tags) {
return $tags->map->stateFor($user)->map->subscription->contains('ignore')
|| !$this->discussion->newQuery()->whereVisibleTo($user)->find($this->discussion->id)
Expand Down
1 change: 1 addition & 0 deletions src/Jobs/SendNotificationWhenDiscussionIsStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function handle(NotificationSyncer $notifications)
->whereIn('tag_user.tag_id', $tagIds->all())
->whereIn('tag_user.subscription', ['follow', 'lurk'])
->get()
->unique()
->reject(function ($user) use ($firstPost, $tags) {
return $tags->map->stateFor($user)->map->subscription->contains('ignore')
|| !$this->discussion->newQuery()->whereVisibleTo($user)->find($this->discussion->id)
Expand Down
1 change: 1 addition & 0 deletions src/Jobs/SendNotificationWhenReplyIsPosted.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function handle(NotificationSyncer $notifications)
->where('tag_user.subscription', 'lurk')
->where('discussion_user.last_read_post_number', '>=', $this->lastPostNumber - 1)
->get()
->unique()
->reject(function (User $user) use ($tags) {
return $tags->map->stateFor($user)->map->subscription->contains('ignore')
|| !$this->post->isVisibleTo($user);
Expand Down

0 comments on commit c04dd09

Please sign in to comment.