3 namespace Friendica\Module\Notifications;
5 use Friendica\BaseModule;
6 use Friendica\Core\System;
8 use Friendica\Network\HTTPException;
11 * Interacting with the /notification command
13 class Notification 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 = [])
24 // @TODO: Replace with parameter from router
25 if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
26 $success = DI::notification()->setAllSeen();
28 header('Content-type: application/json; charset=utf-8');
30 'result' => ($success) ? 'success' : 'fail',
37 * Redirect to the notifications main page or to the url for the chosen notifications
40 * @throws HTTPException\InternalServerErrorException
42 public static function content(array $parameters = [])
44 // @TODO: Replace with parameter from router
45 if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
46 $notificationManager = DI::notification();
47 // @TODO: Replace with parameter from router
48 $note = $notificationManager->getByID(DI::args()->get(2));
50 $notificationManager->setSeen($note);
51 if (!empty($note['link'])) {
52 System::externalRedirect($note['link']);
56 DI::baseUrl()->redirect();
59 // @TODO: Replace with parameter from router
60 DI::baseUrl()->redirect('notifications/system');