diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 7a0f910db6951..986ea2097b4f8 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -701,6 +701,7 @@ 'OCP\\Notification\\IncompleteNotificationException' => $baseDir . '/lib/public/Notification/IncompleteNotificationException.php', 'OCP\\Notification\\IncompleteParsedNotificationException' => $baseDir . '/lib/public/Notification/IncompleteParsedNotificationException.php', 'OCP\\Notification\\InvalidValueException' => $baseDir . '/lib/public/Notification/InvalidValueException.php', + 'OCP\\Notification\\NotificationPreloadReason' => $baseDir . '/lib/public/Notification/NotificationPreloadReason.php', 'OCP\\Notification\\UnknownNotificationException' => $baseDir . '/lib/public/Notification/UnknownNotificationException.php', 'OCP\\OCM\\Events\\ResourceTypeRegisterEvent' => $baseDir . '/lib/public/OCM/Events/ResourceTypeRegisterEvent.php', 'OCP\\OCM\\Exceptions\\OCMArgumentException' => $baseDir . '/lib/public/OCM/Exceptions/OCMArgumentException.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index b8352d41f65c9..ecb634a31cf63 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -742,6 +742,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Notification\\IncompleteNotificationException' => __DIR__ . '/../../..' . '/lib/public/Notification/IncompleteNotificationException.php', 'OCP\\Notification\\IncompleteParsedNotificationException' => __DIR__ . '/../../..' . '/lib/public/Notification/IncompleteParsedNotificationException.php', 'OCP\\Notification\\InvalidValueException' => __DIR__ . '/../../..' . '/lib/public/Notification/InvalidValueException.php', + 'OCP\\Notification\\NotificationPreloadReason' => __DIR__ . '/../../..' . '/lib/public/Notification/NotificationPreloadReason.php', 'OCP\\Notification\\UnknownNotificationException' => __DIR__ . '/../../..' . '/lib/public/Notification/UnknownNotificationException.php', 'OCP\\OCM\\Events\\ResourceTypeRegisterEvent' => __DIR__ . '/../../..' . '/lib/public/OCM/Events/ResourceTypeRegisterEvent.php', 'OCP\\OCM\\Exceptions\\OCMArgumentException' => __DIR__ . '/../../..' . '/lib/public/OCM/Exceptions/OCMArgumentException.php', diff --git a/lib/private/Notification/Manager.php b/lib/private/Notification/Manager.php index 0cbda651a8b88..62fa66df85cd6 100644 --- a/lib/private/Notification/Manager.php +++ b/lib/private/Notification/Manager.php @@ -22,6 +22,7 @@ use OCP\Notification\INotification; use OCP\Notification\INotifier; use OCP\Notification\IPreloadableNotifier; +use OCP\Notification\NotificationPreloadReason; use OCP\Notification\UnknownNotificationException; use OCP\RichObjectStrings\IRichTextFormatter; use OCP\RichObjectStrings\IValidator; @@ -391,14 +392,18 @@ public function prepare(INotification $notification, string $languageCode): INot return $notification; } - public function preloadDataForParsing(array $notifications, string $languageCode): void { + public function preloadDataForParsing( + array $notifications, + string $languageCode, + NotificationPreloadReason $reason, + ): void { $notifiers = $this->getNotifiers(); foreach ($notifiers as $notifier) { if (!($notifier instanceof IPreloadableNotifier)) { continue; } - $notifier->preloadDataForParsing($notifications, $languageCode); + $notifier->preloadDataForParsing($notifications, $languageCode, $reason); } } diff --git a/lib/public/Notification/IPreloadableNotifier.php b/lib/public/Notification/IPreloadableNotifier.php index 2bdcd84d254e2..ac2e98d1f9317 100644 --- a/lib/public/Notification/IPreloadableNotifier.php +++ b/lib/public/Notification/IPreloadableNotifier.php @@ -26,6 +26,11 @@ interface IPreloadableNotifier extends INotifier { * * @param INotification[] $notifications The notifications which are about to be prepared in the next step. * @param string $languageCode The code of the language that should be used to prepare the notification. + * @param NotificationPreloadReason $reason The reason for preloading the given notifications to facilitate smarter decisions about what data to preload. */ - public function preloadDataForParsing(array $notifications, string $languageCode): void; + public function preloadDataForParsing( + array $notifications, + string $languageCode, + NotificationPreloadReason $reason, + ): void; } diff --git a/lib/public/Notification/NotificationPreloadReason.php b/lib/public/Notification/NotificationPreloadReason.php new file mode 100644 index 0000000000000..f7b39cc3e87f8 --- /dev/null +++ b/lib/public/Notification/NotificationPreloadReason.php @@ -0,0 +1,40 @@ +