From 4dd8b9e7d6322b0f0fae6925b8d9039756aa94d5 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 5 Jan 2021 09:36:45 +0100 Subject: [PATCH] Correctly set the user for activity parsing when preparing a notification Signed-off-by: Joas Schilling --- lib/NotificationGenerator.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/NotificationGenerator.php b/lib/NotificationGenerator.php index bc7a28b81..1dd6f2e80 100644 --- a/lib/NotificationGenerator.php +++ b/lib/NotificationGenerator.php @@ -78,13 +78,14 @@ private function getNotificationForEvent(IEvent $event, int $activityId): INotif } private function populateEvent(IEvent $event, string $language) { + $this->activityManager->setFormattingObject($event->getObjectType(), $event->getObjectId()); foreach ($this->activityManager->getProviders() as $provider) { try { - $this->activityManager->setFormattingObject($event->getObjectType(), $event->getObjectId()); $event = $provider->parse($language, $event); } catch (\InvalidArgumentException $e) { } } + $this->activityManager->setFormattingObject('', 0); return $event; } @@ -106,7 +107,9 @@ public function prepare(INotification $notification, string $languageCode): INot if (!$event || $event->getAffectedUser() !== $notification->getUser()) { throw new \InvalidArgumentException(); } + $this->activityManager->setCurrentUserId($notification->getUser()); $event = $this->populateEvent($event, $languageCode); + $this->activityManager->setCurrentUserId(null); return $this->getDisplayNotificationForEvent($event, $event->getObjectId()); }