Skip to content

Commit 17a425e

Browse files
committed
fix(NotificationGenerator): catch InvalidArgumentException from notification setters in prepare()
INotification setters like setRichSubject() and setParsedSubject() throw \InvalidArgumentException for empty/invalid values, which previously escaped prepare() — triggering the NC39 deprecation. Catch and discard the notification as already-processed since it cannot be rendered. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
1 parent 4e3129f commit 17a425e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/NotificationGenerator.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ public function prepare(INotification $notification, string $languageCode): INot
118118
$event = $this->populateEvent($event, $languageCode);
119119
$this->activityManager->setCurrentUserId(null);
120120

121-
return $this->getDisplayNotificationForEvent($event, $event->getObjectId());
121+
try {
122+
return $this->getDisplayNotificationForEvent($event, $event->getObjectId());
123+
} catch (\InvalidArgumentException $e) {
124+
$this->logger->error('Failed to format activity notification', ['exception' => $e]);
125+
throw new AlreadyProcessedException();
126+
}
122127
}
123128

124129
private function getDisplayNotificationForEvent(IEvent $event, int $activityId): INotification {

0 commit comments

Comments
 (0)