mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-28 17:02:04 +03:00
Notifications: Fixed send content permission checking
Added test and changed logic to properly check the view permissions for the notification receiver before sending. Required change to permissions applicator to allow the user to be manually determined, and a service provider update to provide the class as a singleton without a specific user, so it checks the current logged in user on demand.
This commit is contained in:
@ -312,4 +312,21 @@ class WatchTest extends TestCase
|
||||
&& str_contains($mailContent, 'Created By: ' . $admin->name);
|
||||
});
|
||||
}
|
||||
|
||||
public function test_notifications_not_sent_if_lacking_view_permission_for_related_item()
|
||||
{
|
||||
$notifications = Notification::fake();
|
||||
$editor = $this->users->editor();
|
||||
$page = $this->entities->page();
|
||||
|
||||
$watches = new UserEntityWatchOptions($editor, $page);
|
||||
$watches->updateWatchLevel('comments');
|
||||
$this->permissions->disableEntityInheritedPermissions($page);
|
||||
|
||||
$this->asAdmin()->post("/comment/{$page->id}", [
|
||||
'text' => 'My new comment response',
|
||||
])->assertOk();
|
||||
|
||||
$notifications->assertNothingSentTo($editor);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user