Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>tags/v18.0.0beta2
@@ -367,6 +367,7 @@ return array( | |||
'OCP\\Notification\\AlreadyProcessedException' => $baseDir . '/lib/public/Notification/AlreadyProcessedException.php', | |||
'OCP\\Notification\\IAction' => $baseDir . '/lib/public/Notification/IAction.php', | |||
'OCP\\Notification\\IApp' => $baseDir . '/lib/public/Notification/IApp.php', | |||
'OCP\\Notification\\IDismissableNotifier' => $baseDir . '/lib/public/Notification/IDismissableNotifier.php', | |||
'OCP\\Notification\\IManager' => $baseDir . '/lib/public/Notification/IManager.php', | |||
'OCP\\Notification\\INotification' => $baseDir . '/lib/public/Notification/INotification.php', | |||
'OCP\\Notification\\INotifier' => $baseDir . '/lib/public/Notification/INotifier.php', |
@@ -396,6 +396,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c | |||
'OCP\\Notification\\AlreadyProcessedException' => __DIR__ . '/../../..' . '/lib/public/Notification/AlreadyProcessedException.php', | |||
'OCP\\Notification\\IAction' => __DIR__ . '/../../..' . '/lib/public/Notification/IAction.php', | |||
'OCP\\Notification\\IApp' => __DIR__ . '/../../..' . '/lib/public/Notification/IApp.php', | |||
'OCP\\Notification\\IDismissableNotifier' => __DIR__ . '/../../..' . '/lib/public/Notification/IDismissableNotifier.php', | |||
'OCP\\Notification\\IManager' => __DIR__ . '/../../..' . '/lib/public/Notification/IManager.php', | |||
'OCP\\Notification\\INotification' => __DIR__ . '/../../..' . '/lib/public/Notification/INotification.php', | |||
'OCP\\Notification\\INotifier' => __DIR__ . '/../../..' . '/lib/public/Notification/INotifier.php', |
@@ -31,6 +31,7 @@ use OCP\AppFramework\QueryException; | |||
use OCP\ILogger; | |||
use OCP\Notification\AlreadyProcessedException; | |||
use OCP\Notification\IApp; | |||
use OCP\Notification\IDismissableNotifier; | |||
use OCP\Notification\IManager; | |||
use OCP\Notification\INotification; | |||
use OCP\Notification\INotifier; | |||
@@ -296,4 +297,18 @@ class Manager implements IManager { | |||
return $count; | |||
} | |||
public function dismissNotification(INotification $notification): void { | |||
$notifiers = $this->getNotifiers(); | |||
foreach ($notifiers as $notifier) { | |||
if ($notifier instanceof IDismissableNotifier) { | |||
try { | |||
$notifier->dismissNotification($notification); | |||
} catch (\InvalidArgumentException $e) { | |||
continue; | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
<?php | |||
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/>. | |||
* | |||
*/ | |||
namespace OCP\Notification; | |||
/** | |||
* 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 chose to for example do some default action. | |||
* | |||
* @since 18.0.0 | |||
*/ | |||
interface IDismissableNotifier extends INotifier { | |||
/** | |||
* @param INotification $notification | |||
* @throws \InvalidArgumentException In case the handler can't handle the notification | |||
* | |||
* @since 18.0.0 | |||
*/ | |||
public function dismissNotification(INotification $notification): void; | |||
} |
@@ -85,4 +85,9 @@ interface IManager extends IApp, INotifier { | |||
* @since 14.0.0 | |||
*/ | |||
public function isPreparingPushNotification(): bool; | |||
/** | |||
* @since 18.0.0 | |||
*/ | |||
public function dismissNotification(INotification $notification): void; | |||
} |