Skip to content

Commit f969f75

Browse files
committed
feat: indicate reason for preloading notifications
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
1 parent cf0b709 commit f969f75

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

lib/private/Notification/Manager.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use OCP\Notification\INotification;
2323
use OCP\Notification\INotifier;
2424
use OCP\Notification\IPreloadableNotifier;
25+
use OCP\Notification\NotificationPreloadReason;
2526
use OCP\Notification\UnknownNotificationException;
2627
use OCP\RichObjectStrings\IRichTextFormatter;
2728
use OCP\RichObjectStrings\IValidator;
@@ -391,14 +392,18 @@ public function prepare(INotification $notification, string $languageCode): INot
391392
return $notification;
392393
}
393394

394-
public function preloadDataForParsing(array $notifications, string $languageCode): void {
395+
public function preloadDataForParsing(
396+
array $notifications,
397+
string $languageCode,
398+
NotificationPreloadReason $reason,
399+
): void {
395400
$notifiers = $this->getNotifiers();
396401
foreach ($notifiers as $notifier) {
397402
if (!($notifier instanceof IPreloadableNotifier)) {
398403
continue;
399404
}
400405

401-
$notifier->preloadDataForParsing($notifications, $languageCode);
406+
$notifier->preloadDataForParsing($notifications, $languageCode, $reason);
402407
}
403408
}
404409

lib/public/Notification/IPreloadableNotifier.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ interface IPreloadableNotifier extends INotifier {
2626
*
2727
* @param INotification[] $notifications The notifications which are about to be prepared in the next step.
2828
* @param string $languageCode The code of the language that should be used to prepare the notification.
29+
* @param NotificationPreloadReason $reason The reason for preloading the given notifications to facilitate smarter decisions about what data to preload.
2930
*/
30-
public function preloadDataForParsing(array $notifications, string $languageCode): void;
31+
public function preloadDataForParsing(
32+
array $notifications,
33+
string $languageCode,
34+
NotificationPreloadReason $reason,
35+
): void;
3136
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCP\Notification;
11+
12+
/**
13+
* Indicates the reason for preloading notifications to facilitate smarter decisions about what data
14+
* to preload.
15+
*
16+
* @since 32.0.0
17+
*/
18+
enum NotificationPreloadReason {
19+
/**
20+
* Preparing a single notification for many users.
21+
*
22+
* @since 32.0.0
23+
*/
24+
case Push;
25+
26+
/**
27+
* Preparing many notifications for many users.
28+
*
29+
* @since 32.0.0
30+
*/
31+
case Email;
32+
33+
/**
34+
* Preparing many notifications for a single user.
35+
*
36+
* @since 32.0.0
37+
*/
38+
case EndpointController;
39+
}

0 commit comments

Comments
 (0)