mirror of
https://github.com/nextcloud/server.git
synced 2026-02-18 18:28:50 -05:00
feat: indicate reason for preloading notifications
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
parent
6d5dd4b389
commit
f95ce30994
5 changed files with 55 additions and 3 deletions
|
|
@ -701,6 +701,7 @@ return array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use OCP\Notification\IncompleteParsedNotificationException;
|
|||
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 @@ class Manager implements IManager {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
40
lib/public/Notification/NotificationPreloadReason.php
Normal file
40
lib/public/Notification/NotificationPreloadReason.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCP\Notification;
|
||||
|
||||
use OCP\AppFramework\Attribute\Consumable;
|
||||
|
||||
/**
|
||||
* Indicates the reason for preloading notifications to facilitate smarter decisions about what data
|
||||
* to preload.
|
||||
*/
|
||||
#[Consumable(since: '32.0.0')]
|
||||
enum NotificationPreloadReason {
|
||||
/**
|
||||
* Preparing a single notification for many users.
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
case Push;
|
||||
|
||||
/**
|
||||
* Preparing many notifications for many users.
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
case Email;
|
||||
|
||||
/**
|
||||
* Preparing many notifications for a single user.
|
||||
*
|
||||
* @since 32.0.0
|
||||
*/
|
||||
case EndpointController;
|
||||
}
|
||||
Loading…
Reference in a new issue