diff --git a/mod/ping.php b/mod/ping.php index 7e426d1d66..8740bee08a 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -370,6 +370,10 @@ function ping_init(App $a) 'info' => $sysmsgs_info ]; + if (DI::pConfig()->get(local_user(), 'system', 'pause_notification')) { + $data = []; + } + $json_payload = json_encode(["result" => $data]); if (isset($_GET['callback'])) { diff --git a/src/Content/Nav.php b/src/Content/Nav.php index 9e34cefc75..63e16b20e5 100644 --- a/src/Content/Nav.php +++ b/src/Content/Nav.php @@ -268,6 +268,12 @@ class Nav $nav['notifications'] = ['notifications', DI::l10n()->t('Notifications'), '', DI::l10n()->t('Notifications')]; $nav['notifications']['all'] = ['notifications/system', DI::l10n()->t('See all notifications'), '', '']; $nav['notifications']['mark'] = ['', DI::l10n()->t('Mark as seen'), '', DI::l10n()->t('Mark all system notifications seen')]; + + if (DI::pConfig()->get(local_user(), 'system', 'pause_notification')) { + $nav['notifications']['unpause'] = DI::l10n()->t('Unpause'); + } else { + $nav['notifications']['pause'] = DI::l10n()->t('Pause'); + } } $nav['messages'] = ['message', DI::l10n()->t('Messages'), '', DI::l10n()->t('Private mail')]; diff --git a/src/Module/Notifications/Notification.php b/src/Module/Notifications/Notification.php index 2dc008248e..a8d810602c 100644 --- a/src/Module/Notifications/Notification.php +++ b/src/Module/Notifications/Notification.php @@ -22,6 +22,7 @@ namespace Friendica\Module\Notifications; use Friendica\BaseModule; +use Friendica\Core\Logger; use Friendica\Core\System; use Friendica\DI; use Friendica\Module\Security\Login; @@ -76,6 +77,16 @@ class Notification extends BaseModule throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.')); } + if (DI::args()->get(1) === 'pause') { + DI::pConfig()->set(local_user(), 'system', 'pause_notification', true); + $success = true; + } + + if (DI::args()->get(1) === 'unpause') { + DI::pConfig()->set(local_user(), 'system', 'pause_notification', false); + $success = true; + } + if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') { try { $success = DI::notify()->setSeen(); diff --git a/static/routes.config.php b/static/routes.config.php index 6f48500063..3c439699bc 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -231,9 +231,12 @@ return [ '/notification' => [ '[/]' => [Module\Notifications\Notification::class, [R::GET]], + '/pause' => [Module\Notifications\Notification::class, [R::GET]], + '/unpause' => [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}[/{activity}]' => [Module\Objects::class, [R::GET]], '/oembed' => [ diff --git a/view/js/main.js b/view/js/main.js index 35a0529a0e..58a9e77868 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -972,6 +972,26 @@ function notificationMarkAll() { }); } +function notificationPause() { + $.get('notification/pause', function(data) { + if (timer) { + clearTimeout(timer); + } + timer = setTimeout(NavUpdate,1000); + force_update = true; + }); +} + +function notificationUnpause() { + $.get('notification/unpause', function(data) { + if (timer) { + clearTimeout(timer); + } + timer = setTimeout(NavUpdate,1000); + force_update = true; + }); +} + /** * sprintf in javascript * "{0} and {1}".format('zero','uno'); diff --git a/view/templates/nav.tpl b/view/templates/nav.tpl index 07e9469a8c..e892703d1f 100644 --- a/view/templates/nav.tpl +++ b/view/templates/nav.tpl @@ -50,8 +50,10 @@ {{if $nav.notifications}} {{$nav.notifications.1}} -