summaryrefslogtreecommitdiffstats
path: root/lib/Notification/Notifier.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r--lib/Notification/Notifier.php50
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index eeb657bdf..ab81dcf0f 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -23,6 +23,8 @@ declare(strict_types=1);
namespace OCA\Talk\Notification;
+use OC\HintException;
+use OCA\FederatedFileSharing\AddressHandler;
use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Config;
@@ -77,6 +79,8 @@ class Notifier implements INotifier {
protected $messageParser;
/** @var Definitions */
protected $definitions;
+ /** @var AddressHandler */
+ protected $addressHandler;
/** @var Room[] */
protected $rooms = [];
@@ -94,7 +98,8 @@ class Notifier implements INotifier {
INotificationManager $notificationManager,
CommentsManager $commentManager,
MessageParser $messageParser,
- Definitions $definitions) {
+ Definitions $definitions,
+ AddressHandler $addressHandler) {
$this->lFactory = $lFactory;
$this->url = $url;
$this->config = $config;
@@ -107,6 +112,7 @@ class Notifier implements INotifier {
$this->commentManager = $commentManager;
$this->messageParser = $messageParser;
$this->definitions = $definitions;
+ $this->addressHandler = $addressHandler;
}
/**
@@ -258,6 +264,10 @@ class Notifier implements INotifier {
return $this->parseChatMessage($notification, $room, $participant, $l);
}
+ if ($subject === 'remote_talk_share') {
+ return $this->parseRemoteInvitationMessage($notification, $l);
+ }
+
$this->notificationManager->markProcessed($notification);
throw new \InvalidArgumentException('Unknown subject');
}
@@ -271,6 +281,44 @@ class Notifier implements INotifier {
}
/**
+ * @throws HintException
+ */
+ protected function parseRemoteInvitationMessage(INotification $notification, IL10N $l): INotification {
+ $subjectParameters = $notification->getSubjectParameters();
+
+ [$sharedById, $sharedByServer] = $this->addressHandler->splitUserRemote($subjectParameters['sharedByFederatedId']);
+
+ $message = $l->t('{user1} shared room {roomName} on {remoteServer} with you');
+ $parsedMessage = $l->t('{user1} shared room {roomName} on {remoteServer} with you', [
+ 'user1' => $subjectParameters['sharedByFederatedId'],
+ 'roomName' => $subjectParameters['roomName'],
+ 'remoteServer' => $subjectParameters['serverUrl'],
+ ]);
+
+ $notification->setParsedMessage($parsedMessage);
+ $notification->setRichMessage($message, [
+ 'user1' => [
+ 'type' => 'user',
+ 'id' => $sharedById,
+ 'name' => $subjectParameters['sharedByDisplayName'],
+ 'server' => $sharedByServer,
+ ],
+ 'roomName' => [
+ 'type' => 'highlight',
+ 'id' => $subjectParameters['serverUrl'] . '::' . $subjectParameters['roomToken'],
+ 'name' => $subjectParameters['roomName'],
+ ],
+ 'remoteServer' => [
+ 'type' => 'highlight',
+ 'id' => $subjectParameters['serverUrl'],
+ 'name' => $subjectParameters['serverUrl'],
+ ]
+ ]);
+
+ return $notification;
+ }
+
+ /**
* @param INotification $notification
* @param Room $room
* @param Participant $participant