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') {
27 $success = DI::notify()->setAllSeen();
28 }catch (\Exception $e) {
32 header('Content-type: application/json; charset=utf-8');
34 'result' => ($success) ? 'success' : 'fail',
41 * Redirect to the notifications main page or to the url for the chosen notifications
44 * @throws HTTPException\InternalServerErrorException
46 public static function content(array $parameters = [])
48 // @TODO: Replace with parameter from router
49 if (DI::args()->getArgc() > 2 && DI::args()->get(1) === 'view' && intval(DI::args()->get(2))) {
51 $notification = DI::notify()->getByID(DI::args()->get(2));
52 $notification->setSeen();
54 if (!empty($notification->link)) {
55 System::externalRedirect($notification->link);
58 } catch (HTTPException\NotFoundException $e) {
59 info(DI::l10n()->t('Invalid notification.'));
62 DI::baseUrl()->redirect();
65 // @TODO: Replace with parameter from router
66 DI::baseUrl()->redirect('notifications/system');