diff --git a/apps/files_sharing/lib/Notification/Listener.php b/apps/files_sharing/lib/Notification/Listener.php index 1f8358dd3b..9d23898e57 100644 --- a/apps/files_sharing/lib/Notification/Listener.php +++ b/apps/files_sharing/lib/Notification/Listener.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace OCA\Files_Sharing\Notification; -use OC\Share\Share; use OCP\IGroup; use OCP\IGroupManager; use OCP\IUser; @@ -61,12 +60,12 @@ class Listener { $share = $event->getSubject(); $notification = $this->instantiateNotification($share); - if ($share->getShareType() === Share::SHARE_TYPE_USER) { - $notification->setSubject('incoming_user_share') + if ($share->getShareType() === IShare::TYPE_USER) { + $notification->setSubject(Notifier::INCOMING_USER_SHARE) ->setUser($share->getSharedWith()); $this->notificationManager->notify($notification); - } else if ($share->getShareType() === Share::SHARE_TYPE_GROUP) { - $notification->setSubject('incoming_group_share'); + } else if ($share->getShareType() === IShare::TYPE_GROUP) { + $notification->setSubject(Notifier::INCOMING_GROUP_SHARE); $group = $this->groupManager->get($share->getSharedWith()); foreach ($group->getUsers() as $user) { @@ -108,7 +107,7 @@ class Listener { } $notification = $this->instantiateNotification($share); - $notification->setSubject('incoming_group_share') + $notification->setSubject(Notifier::INCOMING_GROUP_SHARE) ->setUser($user->getUID()); $this->notificationManager->notify($notification); } diff --git a/apps/files_sharing/lib/Notification/Notifier.php b/apps/files_sharing/lib/Notification/Notifier.php index 03d7038e6f..57b96be57b 100644 --- a/apps/files_sharing/lib/Notification/Notifier.php +++ b/apps/files_sharing/lib/Notification/Notifier.php @@ -41,6 +41,8 @@ use OCP\Share\IManager; use OCP\Share\IShare; class Notifier implements INotifier { + public const INCOMING_USER_SHARE = 'incoming_user_share'; + public const INCOMING_GROUP_SHARE = 'incoming_group_share'; /** @var IFactory */ protected $l10nFactory; @@ -158,7 +160,7 @@ class Notifier implements INotifier { } switch ($notification->getSubject()) { - case 'incoming_user_share': + case self::INCOMING_USER_SHARE: if ($share->getSharedWith() !== $notification->getUser()) { throw new AlreadyProcessedException(); } @@ -178,7 +180,7 @@ class Notifier implements INotifier { ]; break; - case 'incoming_group_share': + case self::INCOMING_GROUP_SHARE: $user = $this->userManager->get($notification->getUser()); if (!$user instanceof IUser) { throw new AlreadyProcessedException();