From 239766b08793b4826d4bfc93f006e70042a978ca Mon Sep 17 00:00:00 2001 From: sulimanbenhalim Date: Tue, 20 Oct 2026 12:38:42 +0200 Subject: [PATCH] fix: stop star notifications from people you mute --- app/Actions/CreateStarNotification.php | 4 ++-- tests/Unit/Actions/CreateStarNotificationTest.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Actions/CreateStarNotification.php b/app/Actions/CreateStarNotification.php index fa228c710..69c76e1ac 100644 --- a/app/Actions/CreateStarNotification.php +++ b/app/Actions/CreateStarNotification.php @@ -13,11 +13,11 @@ final readonly class CreateStarNotification { /** - * A star notifies the commit's author once while it holds: unstarring removes the notification. + * A star notifies the commit's author once while it holds: unstarring removes the notification. Nobody hears from people they mute. */ public function handle(User $stargazer, Commit $commit): void { - if ($commit->user_id === $stargazer->id) { + if ($commit->user_id === $stargazer->id || $commit->user?->isMuting($stargazer)) { return; } diff --git a/tests/Unit/Actions/CreateStarNotificationTest.php b/tests/Unit/Actions/CreateStarNotificationTest.php index ddfeca976..f8c98f222 100644 --- a/tests/Unit/Actions/CreateStarNotificationTest.php +++ b/tests/Unit/Actions/CreateStarNotificationTest.php @@ -28,6 +28,17 @@ expect($commit->user->notifications()->exists())->toBeFalse(); }); +it('does not notify an author who muted the stargazer', function (): void { + $user = User::factory()->create(); + $commit = Commit::factory()->create(); + + $commit->user->muting()->attach($user); + + resolve(CreateStarNotification::class)->handle($user, $commit); + + expect($commit->user->notifications()->exists())->toBeFalse(); +}); + it('is idempotent', function (): void { $user = User::factory()->create(); $commit = Commit::factory()->create();