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()); }