notification: update comment and api endpoint for marking as read/unread

This commit is contained in:
2021-12-29 17:36:14 +01:00
parent 9d638fe897
commit 8fe94bd117
7 changed files with 302 additions and 16 deletions

View File

@@ -22,9 +22,11 @@ final class NotificationVoter extends Voter
{
public const COMMENT_EDIT = 'CHILL_MAIN_NOTIFICATION_COMMENT_EDIT';
public const SEE = 'CHILL_MAIN_NOTIFICATION_SEE';
public const NOTIFICATION_SEE = 'CHILL_MAIN_NOTIFICATION_SEE';
public const UPDATE = 'CHILL_MAIN_NOTIFICATION_UPDATE';
public const NOTIFICATION_TOGGLE_READ_STATUS = 'CHILL_MAIIN_NOTIFICATION_TOGGLE_READ_STATUS';
public const NOTIFICATION_UPDATE = 'CHILL_MAIN_NOTIFICATION_UPDATE';
protected function supports($attribute, $subject): bool
{
@@ -45,10 +47,11 @@ final class NotificationVoter extends Voter
if ($subject instanceof Notification) {
switch ($attribute) {
case self::SEE:
case self::NOTIFICATION_SEE:
case self::NOTIFICATION_TOGGLE_READ_STATUS:
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
case self::UPDATE:
case self::NOTIFICATION_UPDATE:
return $subject->getSender() === $user;
default: