From 26f22963c51f45af46408fed8fdad43c729f2ac2 Mon Sep 17 00:00:00 2001 From: sodu Date: Tue, 7 Feb 2023 03:40:28 +0500 Subject: [PATCH] added check if a user participates in a thread, if it is the user doesn't receive mention notifications bc the user already getting reply notification. Deleted thread() method from App\Models\reply because it doesn't work since reply has morphtomany relationship with App\Models\Thread issue#937 --- app/Listeners/NotifyUsersMentionedInReply.php | 2 +- app/Models/Reply.php | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/app/Listeners/NotifyUsersMentionedInReply.php b/app/Listeners/NotifyUsersMentionedInReply.php index 8b62bdedf..245bffa26 100644 --- a/app/Listeners/NotifyUsersMentionedInReply.php +++ b/app/Listeners/NotifyUsersMentionedInReply.php @@ -12,7 +12,7 @@ final class NotifyUsersMentionedInReply public function handle(ReplyWasCreated $event): void { $event->reply->mentionedUsers()->each(function ($user) use ($event) { - if (! $user->hasBlocked($event->reply->author())) { + if (! $user->hasBlocked($event->reply->author()) && ! $event->reply->replyAble()->participants()->contains($user)) { $user->notify(new MentionNotification($event->reply)); } }); diff --git a/app/Models/Reply.php b/app/Models/Reply.php index 88acd5b0e..de29e239e 100644 --- a/app/Models/Reply.php +++ b/app/Models/Reply.php @@ -155,11 +155,6 @@ public function spamReportersRelation(): MorphToMany )->withTimestamps(); } - public function thread(): BelongsTo - { - return $this->belongsTo(Thread::class); - } - public function scopeIsSolution(Builder $builder): Builder { return $builder->has('solutionTo');