Browse Source

Merge pull request #54377 from nextcloud/feat/notification-preload-reason

feat: indicate reason for preloading notifications
pull/54494/head
Richard Steinmetz 4 months ago
committed by GitHub
parent
commit
c519e4a22a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      lib/composer/composer/autoload_classmap.php
  2. 1
      lib/composer/composer/autoload_static.php
  3. 9
      lib/private/Notification/Manager.php
  4. 7
      lib/public/Notification/IPreloadableNotifier.php
  5. 40
      lib/public/Notification/NotificationPreloadReason.php

1
lib/composer/composer/autoload_classmap.php

@ -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',

1
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',

9
lib/private/Notification/Manager.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);
}
}

7
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;
}

40
lib/public/Notification/NotificationPreloadReason.php

@ -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…
Cancel
Save