3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\BaseObject;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Model\Notify as ModelNotify;
10 use Friendica\Network\HTTPException;
13 * Interacting with the /notify command
15 class Notify extends BaseModule
17 public static function init(array $parameters = [])
20 throw new HTTPException\UnauthorizedException(L10n::t('Permission denied.'));
24 public static function rawContent(array $parameters = [])
28 // @TODO: Replace with parameter from router
29 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
30 /** @var ModelNotify $notificationsManager */
31 $notificationsManager = self::getClass(ModelNotify::class);
32 $success = $notificationsManager->setAllSeen();
34 header('Content-type: application/json; charset=utf-8');
36 'result' => ($success) ? 'success' : 'fail',
43 * Redirect to the notifications main page or to the url for the chosen notify
46 * @throws HTTPException\InternalServerErrorException
48 public static function content(array $parameters = [])
52 // @TODO: Replace with parameter from router
53 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
54 /** @var ModelNotify $notificationsManager */
55 $notificationsManager = BaseObject::getClass(ModelNotify::class);
56 // @TODO: Replace with parameter from router
57 $note = $notificationsManager->getByID($a->argv[2]);
59 $notificationsManager->setSeen($note);
60 if (!empty($note['link'])) {
61 System::externalRedirect($note['link']);
65 $a->internalRedirect();
68 // @TODO: Replace with parameter from router
69 $a->internalRedirect('notifications/system');