3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 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(array $parameters = [])
19 throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
23 public static function rawContent(array $parameters = [])
27 // @TODO: Replace with parameter from router
28 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
29 $success = DI::notify()->setAllSeen();
31 header('Content-type: application/json; charset=utf-8');
33 'result' => ($success) ? 'success' : 'fail',
40 * Redirect to the notifications main page or to the url for the chosen notify
43 * @throws HTTPException\InternalServerErrorException
45 public static function content(array $parameters = [])
49 // @TODO: Replace with parameter from router
50 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
51 $notificationsManager = DI::notify();
52 // @TODO: Replace with parameter from router
53 $note = $notificationsManager->getByID($a->argv[2]);
55 $notificationsManager->setSeen($note);
56 if (!empty($note['link'])) {
57 System::externalRedirect($note['link']);
61 DI::baseUrl()->redirect();
64 // @TODO: Replace with parameter from router
65 DI::baseUrl()->redirect('notifications/system');