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.'));
23 public static function rawContent()
27 // @TODO: Replace with parameter from router
28 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
29 $notificationsManager = new NotificationsManager();
30 $success = $notificationsManager->setAllSeen();
32 header('Content-type: application/json; charset=utf-8');
34 'result' => ($success) ? 'success' : 'fail',
41 * Redirect to the notifications main page or to the url for the chosen notify
44 * @throws HTTPException\InternalServerErrorException
46 public static function content()
50 // @TODO: Replace with parameter from router
51 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
52 $notificationsManager = new NotificationsManager();
53 // @TODO: Replace with parameter from router
54 $note = $notificationsManager->getByID($a->argv[2]);
56 $notificationsManager->setSeen($note);
57 if (!empty($note['link'])) {
58 System::externalRedirect($note['link']);
62 $a->internalRedirect();
65 // @TODO: Replace with parameter from router
66 $a->internalRedirect('notifications/system');