diff options
Diffstat (limited to 'lib/public/Notification')
-rw-r--r-- | lib/public/Notification/AlreadyProcessedException.php | 27 | ||||
-rw-r--r-- | lib/public/Notification/IAction.php | 30 | ||||
-rw-r--r-- | lib/public/Notification/IApp.php | 30 | ||||
-rw-r--r-- | lib/public/Notification/IDeferrableApp.php | 29 | ||||
-rw-r--r-- | lib/public/Notification/IDismissableNotifier.php | 26 | ||||
-rw-r--r-- | lib/public/Notification/IManager.php | 41 | ||||
-rw-r--r-- | lib/public/Notification/INotification.php | 55 | ||||
-rw-r--r-- | lib/public/Notification/INotifier.php | 31 | ||||
-rw-r--r-- | lib/public/Notification/IPreloadableNotifier.php | 31 | ||||
-rw-r--r-- | lib/public/Notification/IncompleteNotificationException.php | 26 | ||||
-rw-r--r-- | lib/public/Notification/IncompleteParsedNotificationException.php | 26 | ||||
-rw-r--r-- | lib/public/Notification/InvalidValueException.php | 27 | ||||
-rw-r--r-- | lib/public/Notification/UnknownNotificationException.php | 27 |
13 files changed, 126 insertions, 280 deletions
diff --git a/lib/public/Notification/AlreadyProcessedException.php b/lib/public/Notification/AlreadyProcessedException.php index bc200eb71bd..162abd81864 100644 --- a/lib/public/Notification/AlreadyProcessedException.php +++ b/lib/public/Notification/AlreadyProcessedException.php @@ -3,31 +3,14 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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 3009101fed0..722dac72826 100644 --- a/lib/public/Notification/IAction.php +++ b/lib/public/Notification/IAction.php @@ -1,34 +1,16 @@ <?php declare(strict_types=1); - /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ 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 a3ef2771c8a..37c352d44cd 100644 --- a/lib/public/Notification/IApp.php +++ b/lib/public/Notification/IApp.php @@ -1,34 +1,16 @@ <?php declare(strict_types=1); - /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ 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 dad2828cdbd..00c7d691b10 100644 --- a/lib/public/Notification/IDeferrableApp.php +++ b/lib/public/Notification/IDeferrableApp.php @@ -3,33 +3,14 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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 45f7a2aa9db..d2f649b45a1 100644 --- a/lib/public/Notification/IDismissableNotifier.php +++ b/lib/public/Notification/IDismissableNotifier.php @@ -3,37 +3,21 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl> - * - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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 82f0ced07ed..207a89344b0 100644 --- a/lib/public/Notification/IManager.php +++ b/lib/public/Notification/IManager.php @@ -1,39 +1,20 @@ <?php declare(strict_types=1); - /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ 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; @@ -41,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 */ @@ -50,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 b7517326581..a740678376f 100644 --- a/lib/public/Notification/INotification.php +++ b/lib/public/Notification/INotification.php @@ -1,35 +1,16 @@ <?php declare(strict_types=1); - /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCP\Notification; -/** - * Interface INotification - * - * @since 9.0.0 - */ +use OCP\AppFramework\Attribute\Consumable; + +#[Consumable(since: '9.0.0')] interface INotification { /** * @param string $app @@ -154,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 @@ -230,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 @@ -266,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 @@ -275,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 2014f73d5aa..b6851e3dfb3 100644 --- a/lib/public/Notification/INotifier.php +++ b/lib/public/Notification/INotifier.php @@ -1,34 +1,21 @@ <?php declare(strict_types=1); - /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ 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 31551389b43..49d388ebee6 100644 --- a/lib/public/Notification/IncompleteNotificationException.php +++ b/lib/public/Notification/IncompleteNotificationException.php @@ -3,29 +3,14 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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: @@ -36,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 0a8ca8a61e6..c31ab129fd4 100644 --- a/lib/public/Notification/IncompleteParsedNotificationException.php +++ b/lib/public/Notification/IncompleteParsedNotificationException.php @@ -3,29 +3,14 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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 @@ -39,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 6c16ea95036..ec52381ee3c 100644 --- a/lib/public/Notification/InvalidValueException.php +++ b/lib/public/Notification/InvalidValueException.php @@ -3,32 +3,15 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ 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 bfeeb6a14c5..976d9179592 100644 --- a/lib/public/Notification/UnknownNotificationException.php +++ b/lib/public/Notification/UnknownNotificationException.php @@ -3,31 +3,14 @@ declare(strict_types=1); /** - * @copyright Copyright (c) 2024 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace OCP\Notification; -/** - * @since 30.0.0 - */ +use OCP\AppFramework\Attribute\Throwable; + +#[Throwable(since: '30.0.0')] class UnknownNotificationException extends \InvalidArgumentException { } |