diff options
author | Joas Schilling <coding@schilljs.com> | 2023-10-12 15:56:24 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-10-12 15:56:24 +0200 |
commit | b8a47f2870d0d6c036d40cdbbca90421e1a88194 (patch) | |
tree | 421323abc5c07f8b29a887ad9535cc253ad03ed5 | |
parent | 1f0a397ce8f53c331b5e1f64d01f0d77a75c4cd3 (diff) |
fix(federation): Use constants for magic strings
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Federation/BackendNotifier.php | 6 | ||||
-rw-r--r-- | lib/Federation/CloudFederationProviderTalk.php | 16 | ||||
-rw-r--r-- | lib/Federation/FederationManager.php | 3 |
3 files changed, 11 insertions, 14 deletions
diff --git a/lib/Federation/BackendNotifier.php b/lib/Federation/BackendNotifier.php index d3726497d..46de8f4e1 100644 --- a/lib/Federation/BackendNotifier.php +++ b/lib/Federation/BackendNotifier.php @@ -133,7 +133,7 @@ class BackendNotifier { $notification = $this->cloudFederationFactory->getCloudFederationNotification(); $notification->setMessage( - 'SHARE_ACCEPTED', + FederationManager::NOTIFICATION_SHARE_ACCEPTED, FederationManager::TALK_ROOM_RESOURCE, $id, [ @@ -156,7 +156,7 @@ class BackendNotifier { $notification = $this->cloudFederationFactory->getCloudFederationNotification(); $notification->setMessage( - 'SHARE_DECLINED', + FederationManager::NOTIFICATION_SHARE_DECLINED, FederationManager::TALK_ROOM_RESOURCE, $id, [ @@ -180,7 +180,7 @@ class BackendNotifier { $notification = $this->cloudFederationFactory->getCloudFederationNotification(); $notification->setMessage( - 'SHARE_UNSHARED', + FederationManager::NOTIFICATION_SHARE_UNSHARED, FederationManager::TALK_ROOM_RESOURCE, $id, [ diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php index 6132c610b..b59f872a7 100644 --- a/lib/Federation/CloudFederationProviderTalk.php +++ b/lib/Federation/CloudFederationProviderTalk.php @@ -145,21 +145,15 @@ class CloudFederationProviderTalk implements ICloudFederationProvider { throw new BadRequestException(['providerId']); } switch ($notificationType) { - case 'SHARE_ACCEPTED': + case FederationManager::NOTIFICATION_SHARE_ACCEPTED: return $this->shareAccepted((int) $providerId, $notification); - case 'SHARE_DECLINED': + case FederationManager::NOTIFICATION_SHARE_DECLINED: return $this->shareDeclined((int) $providerId, $notification); - case 'SHARE_UNSHARED': + case FederationManager::NOTIFICATION_SHARE_UNSHARED: return $this->shareUnshared((int) $providerId, $notification); - case 'REQUEST_RESHARE': - return []; // TODO: Implement - case 'RESHARE_UNDO': - return []; // TODO: Implement - case 'RESHARE_CHANGE_PERMISSION': - return []; // TODO: Implement } - return []; - // TODO: Implement notificationReceived() method. + + throw new BadRequestException([$notificationType]); } /** diff --git a/lib/Federation/FederationManager.php b/lib/Federation/FederationManager.php index 6f73e8008..9465aef48 100644 --- a/lib/Federation/FederationManager.php +++ b/lib/Federation/FederationManager.php @@ -50,6 +50,9 @@ use OCP\Notification\IManager; class FederationManager { public const TALK_ROOM_RESOURCE = 'talk-room'; public const TALK_PROTOCOL_NAME = 'nctalk'; + public const NOTIFICATION_SHARE_ACCEPTED = 'SHARE_ACCEPTED'; + public const NOTIFICATION_SHARE_DECLINED = 'SHARE_DECLINED'; + public const NOTIFICATION_SHARE_UNSHARED = 'SHARE_UNSHARED'; public const TOKEN_LENGTH = 64; public function __construct( |