Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 7 additions & 2 deletions lib/private/Notification/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
7 changes: 6 additions & 1 deletion lib/public/Notification/IPreloadableNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 40 additions & 0 deletions lib/public/Notification/NotificationPreloadReason.php
Original file line number Diff line number Diff line change
@@ -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