Skip to content

Commit

Permalink
Merge pull request #542 from nextcloud/backport/541/stable20
Browse files Browse the repository at this point in the history
[stable20] Correctly set the user for activity parsing when preparing a notifica…
  • Loading branch information
rullzer authored Jan 5, 2021
2 parents ae0a280 + df4299e commit 938e75c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/NotificationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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());
}
Expand Down

0 comments on commit 938e75c

Please sign in to comment.