3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\Core\NotificationsManager;
7 use Friendica\Core\System;
8 use Friendica\Network\HTTPException;
11 * Interacting with the /notify command
13 class Notify extends BaseModule
16 * @throws HTTPException\InternalServerErrorException
17 * @throws HTTPException\UnauthorizedException
19 public static function rawContent()
22 throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
27 // @TODO: Replace with parameter from router
28 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
29 $notificationsManager = new NotificationsManager();
30 // @TODO: Replace with parameter from router
31 $note = $notificationsManager->getByID($a->argv[2]);
33 $notificationsManager->setSeen($note);
34 if (!empty($note['link'])) {
35 System::externalRedirect($note['link']);
39 $a->internalRedirect();
42 // @TODO: Replace with parameter from router
43 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
44 $notificationsManager = new NotificationsManager();
45 $success = $notificationsManager->setAllSeen();
47 header('Content-type: application/json; charset=utf-8');
49 'result' => ($success) ? 'success' : 'fail',
56 * Redirect to the notifications main page
59 * @throws HTTPException\InternalServerErrorException
61 public static function content()
65 // @TODO: Replace with parameter from router
66 if (($a->argc > 0) && ($a->argv[0] == 'notify')) {
67 $a->internalRedirect('notifications/system');