diff --git a/include/enotify.php b/include/enotify.php index 7567613b4..e21adc91a 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -500,7 +500,7 @@ function notification($params) DI::notify()->update($notification); - $itemlink = DI::baseUrl() . '/notification/view/' . $notification->id; + $itemlink = DI::baseUrl() . '/notification/' . $notification->id; $notify_id = $notification->id; } diff --git a/mod/ping.php b/mod/ping.php index dd57ba34d..70c580d3d 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -443,7 +443,7 @@ function ping_get_notifications($uid) ); } - $notification["href"] = DI::baseUrl() . "/notification/view/" . $notification["id"]; + $notification["href"] = DI::baseUrl() . "/notification/" . $notification["id"]; if ($notification["visible"] && !$notification["deleted"] diff --git a/src/Factory/Notification/Notification.php b/src/Factory/Notification/Notification.php index 2b179cca5..399e6b0e7 100644 --- a/src/Factory/Notification/Notification.php +++ b/src/Factory/Notification/Notification.php @@ -219,7 +219,7 @@ class Notification extends BaseFactory foreach ($notifications as $notification) { $formattedNotifications[] = new \Friendica\Object\Notification\Notification([ 'label' => 'notification', - 'link' => $this->baseUrl->get(true) . '/notification/view/' . $notification->id, + 'link' => $this->baseUrl->get(true) . '/notification/' . $notification->id, 'image' => Proxy::proxifyUrl($notification->photo, false, Proxy::SIZE_MICRO), 'url' => $notification->url, 'text' => strip_tags(BBCode::convert($notification->msg)), 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..6df58374e 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 ($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 @@ -26,14 +46,11 @@ class Notification extends BaseModule try { $success = DI::notify()->setAllSeen(); }catch (\Exception $e) { + DI::logger()->warning('set all seen failed.', ['exception' => $e]); $success = false; } - header('Content-type: application/json; charset=utf-8'); - echo json_encode([ - 'result' => ($success) ? 'success' : 'fail', - ]); - exit(); + System::jsonExit(['result' => (($success) ? 'success' : 'fail')]); } } @@ -45,10 +62,11 @@ class Notification extends BaseModule */ public static function content(array $parameters = []) { - // @TODO: Replace with parameter from router - if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) { + $request_id = $parameters['id'] ?? false; + + if ($request_id) { try { - $notification = DI::notify()->getByID(DI::args()->get(2)); + $notification = DI::notify()->getByID($request_id); $notification->setSeen(); if (!empty($notification->link)) { @@ -62,7 +80,7 @@ class Notification extends BaseModule DI::baseUrl()->redirect(); } - // @TODO: Replace with parameter from router DI::baseUrl()->redirect('notifications/system'); } } + diff --git a/static/routes.config.php b/static/routes.config.php index c081dba66..4aad69d8c 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -184,9 +184,9 @@ 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]], + '/mark/all' => [Module\Notifications\Notification::class, [R::GET]], + '/{id:\d+}' => [Module\Notifications\Notification::class, [R::GET, 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..b04c19c18 100644 --- a/view/templates/notifications/intros.tpl +++ b/view/templates/notifications/intros.tpl @@ -12,7 +12,7 @@
{{$lbl_knowyou}} {{$knowyou}}
{{$note}}
-
+ {{if $discard}}{{/if}}
diff --git a/view/templates/notifications/suggestions.tpl b/view/templates/notifications/suggestions.tpl index d7bb7b601..d0c013ac5 100644 --- a/view/templates/notifications/suggestions.tpl +++ b/view/templates/notifications/suggestions.tpl @@ -8,7 +8,7 @@ {{$fullname}}
{{$note}}
-
+
diff --git a/view/theme/frio/templates/notifications/intros.tpl b/view/theme/frio/templates/notifications/intros.tpl index 4bab6fa96..8f4fa6218 100644 --- a/view/theme/frio/templates/notifications/intros.tpl +++ b/view/theme/frio/templates/notifications/intros.tpl @@ -13,7 +13,7 @@