3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\Core\NotificationsManager;
8 use Friendica\Core\System;
9 use Friendica\Network\HTTPException;
12 * Interacting with the /notify command
14 class Notify extends BaseModule
16 public static function init()
19 throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
24 // @TODO: Replace with parameter from router
25 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
26 $notificationsManager = new NotificationsManager();
27 // @TODO: Replace with parameter from router
28 $note = $notificationsManager->getByID($a->argv[2]);
30 $notificationsManager->setSeen($note);
31 if (!empty($note['link'])) {
32 System::externalRedirect($note['link']);
36 $a->internalRedirect();
40 public static function rawContent()
44 // @TODO: Replace with parameter from router
45 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
46 $notificationsManager = new NotificationsManager();
47 $success = $notificationsManager->setAllSeen();
49 header('Content-type: application/json; charset=utf-8');
51 'result' => ($success) ? 'success' : 'fail',
58 * Redirect to the notifications main page
61 * @throws HTTPException\InternalServerErrorException
63 public static function content()
67 // @TODO: Replace with parameter from router
68 $a->internalRedirect('notifications/system');