3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\BaseObject;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
10 use Friendica\Model\Notify as ModelNotify;
11 use Friendica\Network\HTTPException;
14 * Interacting with the /notify command
16 class Notify extends BaseModule
18 public static function init(array $parameters = [])
21 throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
25 public static function rawContent(array $parameters = [])
29 // @TODO: Replace with parameter from router
30 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
31 /** @var ModelNotify $notificationsManager */
32 $notificationsManager = self::getClass(ModelNotify::class);
33 $success = $notificationsManager->setAllSeen();
35 header('Content-type: application/json; charset=utf-8');
37 'result' => ($success) ? 'success' : 'fail',
44 * Redirect to the notifications main page or to the url for the chosen notify
47 * @throws HTTPException\InternalServerErrorException
49 public static function content(array $parameters = [])
53 // @TODO: Replace with parameter from router
54 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
55 /** @var ModelNotify $notificationsManager */
56 $notificationsManager = BaseObject::getClass(ModelNotify::class);
57 // @TODO: Replace with parameter from router
58 $note = $notificationsManager->getByID($a->argv[2]);
60 $notificationsManager->setSeen($note);
61 if (!empty($note['link'])) {
62 System::externalRedirect($note['link']);
66 $a->internalRedirect();
69 // @TODO: Replace with parameter from router
70 $a->internalRedirect('notifications/system');