diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-05-26 00:53:07 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-10 17:26:50 +0300 |
commit | c99a6494e6934b8fe7f2fe05dd39d0af525067b2 (patch) | |
tree | a8eb2e8abc5e3ee9525ad065d0ea522cac32eeb5 /lib/Notification/Notifier.php | |
parent | 3465fc9ca23151b7a8c9c1bceb8612655bfbf9a2 (diff) |
Add notifications for changed state of the hosted signaling server account
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r-- | lib/Notification/Notifier.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index bdacd49cb..2a8f4787c 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -201,6 +201,10 @@ class Notifier implements INotifier { $l = $this->lFactory->get('spreed', $languageCode); + if ($notification->getObjectType() === 'hosted-signaling-server') { + return $this->parseHostedSignalingServer($notification, $l); + } + try { $room = $this->getRoom($notification->getObjectId()); } catch (RoomNotFoundException $e) { @@ -652,4 +656,36 @@ class Notifier implements INotifier { return $notification; } + + protected function parseHostedSignalingServer(INotification $notification, IL10N $l): INotification { + $action = $notification->createAction(); + $action->setLabel($l->t('Open settings')) + ->setParsedLabel($l->t('Open settings')) + ->setLink($notification->getLink(), IAction::TYPE_WEB) + ->setPrimary(true); + + switch ($notification->getSubject()) { + case 'added': + $subject = $l->t('The hosted signaling server is now configured and will be used.'); + break; + case 'removed': + $subject = $l->t('The hosted signaling server was removed and will not be used anymore.'); + break; + case 'changed-status': + $subject = $l->t('The hosted signaling server account has changed the status from "{oldstatus}" to "{newstatus}".'); + + $parameters = $notification->getSubjectParameters(); + $subject = str_replace( + ['{oldstatus}', '{newstatus}'], + [$parameters['oldstatus'], $parameters['newstatus']], + $subject + ); + break; + } + + return $notification + ->setParsedSubject($subject) + ->setIcon($notification->getIcon()) + ->addParsedAction($action); + } } |