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 post(array $parameters = [])
24 $request_id = $parameters['id'] ?? false;
27 $intro = DI::intro()->selectFirst(['id' => $request_id, 'uid' => local_user()]);
29 switch ($_POST['submit']) {
30 case DI::l10n()->t('Discard'):
33 case DI::l10n()->t('Ignore'):
38 DI::baseUrl()->redirect('notifications/intros');
42 public static function rawContent(array $parameters = [])
44 // @TODO: Replace with parameter from router
45 if (DI::args()->get(1) === 'mark' && DI::args()->get(2) === 'all') {
47 $success = DI::notify()->setSeen();
48 } catch (\Exception $e) {
49 DI::logger()->warning('set all seen failed.', ['exception' => $e]);
53 System::jsonExit(['result' => (($success) ? 'success' : 'fail')]);
58 * Redirect to the notifications main page or to the url for the chosen notifications
61 * @throws HTTPException\InternalServerErrorException
63 public static function content(array $parameters = [])
65 $request_id = $parameters['id'] ?? false;
69 $notify = DI::notify()->getByID($request_id);
70 DI::notify()->setSeen(true, $notify);
72 if (!empty($notify->link)) {
73 System::externalRedirect($notify->link);
76 } catch (HTTPException\NotFoundException $e) {
77 info(DI::l10n()->t('Invalid notification.'));
80 DI::baseUrl()->redirect();
83 DI::baseUrl()->redirect('notifications/system');