summaryrefslogtreecommitdiffstats
path: root/lib/Notification/Notifier.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-10-11 07:26:12 +0200
committerJoas Schilling <coding@schilljs.com>2023-10-11 07:41:53 +0200
commit4659794b6f463646a05ac1e63e35dc60a4a081ed (patch)
tree78d68b3decc39d993200548ba15a57a47faa9d0f /lib/Notification/Notifier.php
parent2f0b22f49dcb2d5bad54682aefb604bc331d632f (diff)
fix(federation): Remove notifications when the invite or room is invalid/not found
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification/Notifier.php')
-rw-r--r--lib/Notification/Notifier.php17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php
index 0c8798339..2595b1bc7 100644
--- a/lib/Notification/Notifier.php
+++ b/lib/Notification/Notifier.php
@@ -31,6 +31,7 @@ use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Config;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
+use OCA\Talk\Federation\FederationManager;
use OCA\Talk\GuestManager;
use OCA\Talk\Manager;
use OCA\Talk\Model\Attendee;
@@ -45,7 +46,6 @@ use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\Files\IRootFolder;
-use OCP\HintException;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IURLGenerator;
@@ -90,6 +90,7 @@ class Notifier implements INotifier {
protected Definitions $definitions,
protected AddressHandler $addressHandler,
protected BotServerMapper $botServerMapper,
+ protected FederationManager $federationManager,
) {
$this->commentManager = $commentManager;
}
@@ -395,12 +396,20 @@ class Notifier implements INotifier {
return $notification;
}
- /**
- * @throws HintException
- */
protected function parseRemoteInvitationMessage(INotification $notification, IL10N $l): INotification {
$subjectParameters = $notification->getSubjectParameters();
+ try {
+ $invite = $this->federationManager->getRemoteShareById((int) $notification->getObjectId());
+ if ($invite->getUserId() !== $notification->getUser()) {
+ throw new AlreadyProcessedException();
+ }
+ $this->manager->getRoomById($invite->getRoomId());
+ } catch (RoomNotFoundException $e) {
+ // Room does not exist
+ throw new AlreadyProcessedException();
+ }
+
[$sharedById, $sharedByServer] = $this->addressHandler->splitUserRemote($subjectParameters['sharedByFederatedId']);
$message = $l->t('{user1} shared room {roomName} on {remoteServer} with you');