3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\Core\System;
8 use Friendica\Network\HTTPException;
11 * Interacting with the /notify command
13 class Notify extends BaseModule
15 public static function init(array $parameters = [])
18 throw new HTTPException\UnauthorizedException(DI::l10n()->t('Permission denied.'));
22 public static function rawContent(array $parameters = [])
26 // @TODO: Replace with parameter from router
27 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
28 $success = DI::notify()->setAllSeen();
30 header('Content-type: application/json; charset=utf-8');
32 'result' => ($success) ? 'success' : 'fail',
39 * Redirect to the notifications main page or to the url for the chosen notify
42 * @throws HTTPException\InternalServerErrorException
44 public static function content(array $parameters = [])
48 // @TODO: Replace with parameter from router
49 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
50 $notificationsManager = DI::notify();
51 // @TODO: Replace with parameter from router
52 $note = $notificationsManager->getByID($a->argv[2]);
54 $notificationsManager->setSeen($note);
55 if (!empty($note['link'])) {
56 System::externalRedirect($note['link']);
60 DI::baseUrl()->redirect();
63 // @TODO: Replace with parameter from router
64 DI::baseUrl()->redirect('notifications/system');