diff options
Diffstat (limited to 'lib/public/Notification')
-rw-r--r-- | lib/public/Notification/AlreadyProcessedException.php | 6 | ||||
-rw-r--r-- | lib/public/Notification/IAction.php | 8 | ||||
-rw-r--r-- | lib/public/Notification/IApp.php | 8 | ||||
-rw-r--r-- | lib/public/Notification/IDeferrableApp.php | 8 | ||||
-rw-r--r-- | lib/public/Notification/IDismissableNotifier.php | 5 | ||||
-rw-r--r-- | lib/public/Notification/IManager.php | 18 | ||||
-rw-r--r-- | lib/public/Notification/INotification.php | 32 | ||||
-rw-r--r-- | lib/public/Notification/INotifier.php | 9 | ||||
-rw-r--r-- | lib/public/Notification/IPreloadableNotifier.php | 31 | ||||
-rw-r--r-- | lib/public/Notification/IncompleteNotificationException.php | 5 | ||||
-rw-r--r-- | lib/public/Notification/IncompleteParsedNotificationException.php | 5 | ||||
-rw-r--r-- | lib/public/Notification/InvalidValueException.php | 6 | ||||
-rw-r--r-- | lib/public/Notification/UnknownNotificationException.php | 6 |
13 files changed, 97 insertions, 50 deletions
diff --git a/lib/public/Notification/AlreadyProcessedException.php b/lib/public/Notification/AlreadyProcessedException.php index 0e7458185ff..162abd81864 100644 --- a/lib/public/Notification/AlreadyProcessedException.php +++ b/lib/public/Notification/AlreadyProcessedException.php @@ -8,9 +8,9 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * @since 17.0.0 - */ +use OCP\AppFramework\Attribute\Throwable; + +#[Throwable(since: '17.0.0')] class AlreadyProcessedException extends \RuntimeException { /** * @since 17.0.0 diff --git a/lib/public/Notification/IAction.php b/lib/public/Notification/IAction.php index f1cffa49075..722dac72826 100644 --- a/lib/public/Notification/IAction.php +++ b/lib/public/Notification/IAction.php @@ -8,11 +8,9 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * Interface IAction - * - * @since 9.0.0 - */ +use OCP\AppFramework\Attribute\Consumable; + +#[Consumable(since: '9.0.0')] interface IAction { /** * @since 17.0.0 diff --git a/lib/public/Notification/IApp.php b/lib/public/Notification/IApp.php index 1574ae8a091..37c352d44cd 100644 --- a/lib/public/Notification/IApp.php +++ b/lib/public/Notification/IApp.php @@ -8,11 +8,9 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * Interface IApp - * - * @since 9.0.0 - */ +use OCP\AppFramework\Attribute\Implementable; + +#[Implementable(since: '9.0.0')] interface IApp { /** * @param INotification $notification diff --git a/lib/public/Notification/IDeferrableApp.php b/lib/public/Notification/IDeferrableApp.php index 1820ed7ecd6..00c7d691b10 100644 --- a/lib/public/Notification/IDeferrableApp.php +++ b/lib/public/Notification/IDeferrableApp.php @@ -8,11 +8,9 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * Interface IDeferrableApp - * - * @since 20.0.0 - */ +use OCP\AppFramework\Attribute\Implementable; + +#[Implementable(since: '20.0.0')] interface IDeferrableApp extends IApp { /** * Start deferring notifications until `flush()` is called diff --git a/lib/public/Notification/IDismissableNotifier.php b/lib/public/Notification/IDismissableNotifier.php index 39f9658a8c4..d2f649b45a1 100644 --- a/lib/public/Notification/IDismissableNotifier.php +++ b/lib/public/Notification/IDismissableNotifier.php @@ -8,15 +8,16 @@ declare(strict_types=1); */ namespace OCP\Notification; +use OCP\AppFramework\Attribute\Implementable; + /** * Interface INotifier classes should implement if they want to process notifications * that are dismissed by the user. * * This can be useful if dismissing the notification will leave it in an incomplete * state. The handler can choose to for example do some default action. - * - * @since 18.0.0 */ +#[Implementable(since: '18.0.0')] interface IDismissableNotifier extends INotifier { /** * @param INotification $notification diff --git a/lib/public/Notification/IManager.php b/lib/public/Notification/IManager.php index 6a16af2d7a0..207a89344b0 100644 --- a/lib/public/Notification/IManager.php +++ b/lib/public/Notification/IManager.php @@ -8,15 +8,13 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * Interface IManager - * - * @since 9.0.0 - */ -interface IManager extends IApp, INotifier { +use OCP\AppFramework\Attribute\Consumable; + +#[Consumable(since: '9.0.0')] +interface IManager extends IApp, IPreloadableNotifier { /** * @param string $appClass The service must implement IApp, otherwise a - * \InvalidArgumentException is thrown later + * \InvalidArgumentException is thrown later * @since 17.0.0 */ public function registerApp(string $appClass): void; @@ -24,8 +22,8 @@ interface IManager extends IApp, INotifier { /** * @param \Closure $service The service must implement INotifier, otherwise a * \InvalidArgumentException is thrown later - * @param \Closure $info An array with the keys 'id' and 'name' containing - * the app id and the app name + * @param \Closure $info An array with the keys 'id' and 'name' containing + * the app id and the app name * @deprecated 17.0.0 use registerNotifierService instead. * @since 8.2.0 - Parameter $info was added in 9.0.0 */ @@ -33,7 +31,7 @@ interface IManager extends IApp, INotifier { /** * @param string $notifierService The service must implement INotifier, otherwise a - * \InvalidArgumentException is thrown later + * \InvalidArgumentException is thrown later * @since 17.0.0 * @deprecated 22.0.0 use the IBootStrap registration context */ diff --git a/lib/public/Notification/INotification.php b/lib/public/Notification/INotification.php index 28d2d6bff5a..a740678376f 100644 --- a/lib/public/Notification/INotification.php +++ b/lib/public/Notification/INotification.php @@ -8,11 +8,9 @@ declare(strict_types=1); */ namespace OCP\Notification; -/** - * Interface INotification - * - * @since 9.0.0 - */ +use OCP\AppFramework\Attribute\Consumable; + +#[Consumable(since: '9.0.0')] interface INotification { /** * @param string $app @@ -137,7 +135,7 @@ interface INotification { * See https://github.com/nextcloud/server/issues/1706 for more information. * * @param string $subject - * @param array $parameters + * @param array<string, array<string, string>> $parameters * @return $this * @throws InvalidValueException if the subject or parameters are invalid * @since 11.0.0 @@ -213,7 +211,7 @@ interface INotification { * See https://github.com/nextcloud/server/issues/1706 for more information. * * @param string $message - * @param array $parameters + * @param array<string, array<string, string>> $parameters * @return $this * @throws InvalidValueException if the message or parameters are invalid * @since 11.0.0 @@ -249,6 +247,10 @@ interface INotification { public function getLink(): string; /** + * Set the absolute url for the icon (should be colored black or not have a color) + * + * It's automatically color inverted by clients when needed + * * @param string $icon * @return $this * @throws InvalidValueException if the icon is invalid @@ -258,12 +260,28 @@ interface INotification { public function setIcon(string $icon): INotification; /** + * Get the absolute url for the icon (should be colored black or not have a color) + * + * It's automatically color inverted by clients when needed + * * @return string * @since 11.0.0 */ public function getIcon(): string; /** + * @return $this + * @throws InvalidValueException if the app is not allowed to send priority notifications + * @since 31.0.0 + */ + public function setPriorityNotification(bool $priorityNotification): INotification; + + /** + * @since 31.0.0 + */ + public function isPriorityNotification(): bool; + + /** * @return IAction * @since 9.0.0 */ diff --git a/lib/public/Notification/INotifier.php b/lib/public/Notification/INotifier.php index 39a962b0392..b6851e3dfb3 100644 --- a/lib/public/Notification/INotifier.php +++ b/lib/public/Notification/INotifier.php @@ -8,11 +8,14 @@ declare(strict_types=1); */ namespace OCP\Notification; +use OCP\AppFramework\Attribute\Implementable; + /** - * Interface INotifier - * - * @since 9.0.0 + * Please consider implementing {@see IPreloadableNotifier} to improve performance. It allows to + * preload and cache data for many notifications at once instead of loading the data for each + * prepared notification separately. */ +#[Implementable(since: '9.0.0')] interface INotifier { /** * Identifier of the notifier, only use [a-z0-9_] diff --git a/lib/public/Notification/IPreloadableNotifier.php b/lib/public/Notification/IPreloadableNotifier.php new file mode 100644 index 00000000000..2bdcd84d254 --- /dev/null +++ b/lib/public/Notification/IPreloadableNotifier.php @@ -0,0 +1,31 @@ +<?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\Implementable; + +/** + * Allow notifier implementations to preload and cache data for many notifications at once to + * improve performance by, for example, bundling SQL queries. + */ +#[Implementable(since: '32.0.0')] +interface IPreloadableNotifier extends INotifier { + /** + * This method provides a way for notifier implementations to preload and cache data for many + * notifications. The data is meant to be consumed later in the {@see INotifier::prepare()} + * method to improve performance. + * + * @since 32.0.0 + * + * @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. + */ + public function preloadDataForParsing(array $notifications, string $languageCode): void; +} diff --git a/lib/public/Notification/IncompleteNotificationException.php b/lib/public/Notification/IncompleteNotificationException.php index f5ae5254509..49d388ebee6 100644 --- a/lib/public/Notification/IncompleteNotificationException.php +++ b/lib/public/Notification/IncompleteNotificationException.php @@ -9,6 +9,8 @@ declare(strict_types=1); namespace OCP\Notification; +use OCP\AppFramework\Attribute\Catchable; + /** * Thrown when {@see \OCP\Notification\IManager::notify()} is called with a notification * that does not have all required fields set: @@ -19,8 +21,7 @@ namespace OCP\Notification; * - objectType * - objectId * - subject - * - * @since 30.0.0 */ +#[Catchable(since: '30.0.0')] class IncompleteNotificationException extends \InvalidArgumentException { } diff --git a/lib/public/Notification/IncompleteParsedNotificationException.php b/lib/public/Notification/IncompleteParsedNotificationException.php index b69967e2781..c31ab129fd4 100644 --- a/lib/public/Notification/IncompleteParsedNotificationException.php +++ b/lib/public/Notification/IncompleteParsedNotificationException.php @@ -9,6 +9,8 @@ declare(strict_types=1); namespace OCP\Notification; +use OCP\AppFramework\Attribute\Catchable; + /** * Thrown when {@see \OCP\Notification\IManager::prepare()} is called with a notification * that does not have all required fields set at the end of the manager or after a INotifier @@ -22,8 +24,7 @@ namespace OCP\Notification; * - objectType * - objectId * - parsedSubject - * - * @since 30.0.0 */ +#[Catchable(since: '30.0.0')] class IncompleteParsedNotificationException extends \InvalidArgumentException { } diff --git a/lib/public/Notification/InvalidValueException.php b/lib/public/Notification/InvalidValueException.php index 05cf1a253b2..ec52381ee3c 100644 --- a/lib/public/Notification/InvalidValueException.php +++ b/lib/public/Notification/InvalidValueException.php @@ -9,9 +9,9 @@ declare(strict_types=1); namespace OCP\Notification; -/** - * @since 30.0.0 - */ +use OCP\AppFramework\Attribute\Catchable; + +#[Catchable(since: '30.0.0')] class InvalidValueException extends \InvalidArgumentException { /** * @since 30.0.0 diff --git a/lib/public/Notification/UnknownNotificationException.php b/lib/public/Notification/UnknownNotificationException.php index 7e630c59dd0..976d9179592 100644 --- a/lib/public/Notification/UnknownNotificationException.php +++ b/lib/public/Notification/UnknownNotificationException.php @@ -9,8 +9,8 @@ declare(strict_types=1); namespace OCP\Notification; -/** - * @since 30.0.0 - */ +use OCP\AppFramework\Attribute\Throwable; + +#[Throwable(since: '30.0.0')] class UnknownNotificationException extends \InvalidArgumentException { } |