diff --git a/src/Module/BaseNotifications.php b/src/Module/BaseNotifications.php index 9a67bb566..4deb2a24c 100644 --- a/src/Module/BaseNotifications.php +++ b/src/Module/BaseNotifications.php @@ -75,30 +75,6 @@ abstract class BaseNotifications extends BaseModule self::$showAll = ($_REQUEST['show'] ?? '') === 'all'; } - public static function post(array $parameters = []) - { - $request_id = DI::args()->get(1); - - if ($request_id === 'all') { - return; - } - - if ($request_id) { - $intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]); - - switch ($_POST['submit']) { - case DI::l10n()->t('Discard'): - $intro->discard(); - break; - case DI::l10n()->t('Ignore'): - $intro->ignore(); - break; - } - - DI::baseUrl()->redirect('notifications/intros'); - } - } - public static function rawContent(array $parameters = []) { // If the last argument of the query is NOT json, return diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 9b252562c..20530e81a 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -19,6 +19,26 @@ class Notification extends BaseModule } } + public static function post(array $parameters = []) + { + $request_id = $parameters['id'] ?? false; + + if (DI::args()->get(1) == 'action' && $request_id) { + $intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]); + + switch ($_POST['submit']) { + case DI::l10n()->t('Discard'): + $intro->discard(); + break; + case DI::l10n()->t('Ignore'): + $intro->ignore(); + break; + } + + DI::baseUrl()->redirect('notifications/intros'); + } + } + public static function rawContent(array $parameters = []) { // @TODO: Replace with parameter from router diff --git a/static/routes.config.php b/static/routes.config.php index c081dba66..2dd6da1bf 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -184,9 +184,10 @@ return [ ], '/notification' => [ - '[/]' => [Module\Notifications\Notification::class, [R::GET]], - '/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]], - '/mark/all' => [Module\Notifications\Notification::class, [R::GET]], + '[/]' => [Module\Notifications\Notification::class, [R::GET]], + '/view/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET]], + '/mark/all' => [Module\Notifications\Notification::class, [R::GET]], + '/action/{id:\d+}' => [Module\Notifications\Notification::class, [ R::POST]], ], '/objects/{guid}' => [Module\Objects::class, [R::GET]], diff --git a/view/templates/notifications/intros.tpl b/view/templates/notifications/intros.tpl index 808f155b9..4ad96c727 100644 --- a/view/templates/notifications/intros.tpl +++ b/view/templates/notifications/intros.tpl @@ -12,7 +12,7 @@