From ce6cb58612a6115e8280181192591b6b9dbac556 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Thu, 27 Apr 2023 14:35:43 +0100 Subject: [PATCH] chore: drop unused visibility checking in notif syncer Signed-off-by: Sami Mazouz --- .../src/Notification/NotificationSyncer.php | 18 -------- .../notification/NotificationSyncerTest.php | 46 ------------------- 2 files changed, 64 deletions(-) diff --git a/framework/core/src/Notification/NotificationSyncer.php b/framework/core/src/Notification/NotificationSyncer.php index 752538cab5..4f5fe41aa2 100644 --- a/framework/core/src/Notification/NotificationSyncer.php +++ b/framework/core/src/Notification/NotificationSyncer.php @@ -75,12 +75,6 @@ public function sync(Blueprint\BlueprintInterface $blueprint, array $users) continue; } - // To add access checking on notification subjects, we first attempt - // to load visible subjects to this user. - if (! $this->userCanSeeSubject($user, $blueprint->getSubject())) { - continue; - } - $existing = $toDelete->first(function ($notification) use ($user) { return $notification->user_id === $user->id; }); @@ -168,18 +162,6 @@ protected function setDeleted(array $ids, $isDeleted) Notification::whereIn('id', $ids)->update(['is_deleted' => $isDeleted]); } - /** - * Check access to determine if the recipient is allowed to receive the notification. - */ - protected function userCanSeeSubject(User $user, ?AbstractModel $subject): bool - { - if ($subject && method_exists($subject, 'registerVisibilityScoper')) { - return (bool) $subject->newQuery()->whereVisibleTo($user)->find($subject->id); - } - - return true; - } - /** * Adds a notification driver to the list. * diff --git a/framework/core/tests/integration/notification/NotificationSyncerTest.php b/framework/core/tests/integration/notification/NotificationSyncerTest.php index cbe9287eab..114c10730b 100644 --- a/framework/core/tests/integration/notification/NotificationSyncerTest.php +++ b/framework/core/tests/integration/notification/NotificationSyncerTest.php @@ -50,35 +50,6 @@ protected function setUp(): void ]); } - /** - * @dataProvider visibleSubjectsProvider - * @param class-string $subjectClass - * @test - */ - public function can_receive_notification_for_visible_subjects(string $subjectClass, int $subjectId, string $serializer) - { - $this->expect_notification_count_from_sending_notification_type_with_subject( - 2, - $subjectClass, - $subjectId, - $serializer - ); - } - - /** - * @dataProvider invisibleSubjectsProvider - * @test - */ - public function cannot_receive_notification_for_restricted_subjects(string $subjectClass, int $subjectId, string $serializer) - { - $this->expect_notification_count_from_sending_notification_type_with_subject( - 0, - $subjectClass, - $subjectId, - $serializer - ); - } - /** * @param class-string $subjectClass */ @@ -112,23 +83,6 @@ protected function expect_notification_count_from_sending_notification_type_with ->count() ); } - - public function visibleSubjectsProvider() - { - return [ - [Post::class, 1, BasicPostSerializer::class], - [Discussion::class, 1, BasicDiscussionSerializer::class], - ]; - } - - public function invisibleSubjectsProvider() - { - return [ - [Post::class, 2, BasicPostSerializer::class], - [Discussion::class, 2, BasicDiscussionSerializer::class], - [Post::class, 3, BasicPostSerializer::class], - ]; - } } class CustomNotificationType implements BlueprintInterface