diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 9e945dff4..19eb4db1e 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -25,6 +25,7 @@ use OCA\Polls\AppConstants; use OCA\Polls\Service\PollService; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; @@ -46,9 +47,7 @@ public function __construct( parent::__construct($appName, $request, $session); } - /** - * @NoCSRFRequired - */ + #[NoCSRFRequired] public function index(): TemplateResponse { Util::addScript(AppConstants::APP_ID, 'polls-main'); $this->eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent()); diff --git a/lib/Controller/BaseApiController.php b/lib/Controller/BaseApiController.php index 93879094e..ca62fac5f 100644 --- a/lib/Controller/BaseApiController.php +++ b/lib/Controller/BaseApiController.php @@ -29,6 +29,7 @@ use OCP\AppFramework\ApiController; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -45,8 +46,8 @@ public function __construct( /** * response - * @NoAdminRequired */ + #[NoAdminRequired] protected function response(Closure $callback): JSONResponse { try { return new JSONResponse($callback(), Http::STATUS_OK); @@ -57,8 +58,8 @@ protected function response(Closure $callback): JSONResponse { /** * response - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseLong(Closure $callback): JSONResponse { try { return new JSONResponse($callback(), Http::STATUS_OK); @@ -69,8 +70,8 @@ protected function responseLong(Closure $callback): JSONResponse { /** * responseCreate - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseCreate(Closure $callback): JSONResponse { try { return new JSONResponse($callback(), Http::STATUS_CREATED); @@ -81,8 +82,8 @@ protected function responseCreate(Closure $callback): JSONResponse { /** * responseDeleteTolerant - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseDeleteTolerant(Closure $callback): JSONResponse { try { return new JSONResponse($callback(), Http::STATUS_OK); diff --git a/lib/Controller/BaseController.php b/lib/Controller/BaseController.php index c989ecec9..ea25695a0 100644 --- a/lib/Controller/BaseController.php +++ b/lib/Controller/BaseController.php @@ -29,6 +29,7 @@ use OCP\AppFramework\Controller; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -44,8 +45,8 @@ public function __construct( /** * response - * @NoAdminRequired */ + #[NoAdminRequired] protected function response(Closure $callback, string $token = ''): JSONResponse { if ($token) { $this->session->set('publicPollToken', $token); @@ -60,8 +61,8 @@ protected function response(Closure $callback, string $token = ''): JSONResponse /** * response - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseLong(Closure $callback, string $token = ''): JSONResponse { if ($token) { $this->session->set('publicPollToken', $token); @@ -76,8 +77,8 @@ protected function responseLong(Closure $callback, string $token = ''): JSONResp /** * responseCreate - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseCreate(Closure $callback, string $token = ''): JSONResponse { if ($token) { $this->session->set('publicPollToken', $token); @@ -92,8 +93,8 @@ protected function responseCreate(Closure $callback, string $token = ''): JSONRe /** * responseDeleteTolerant - * @NoAdminRequired */ + #[NoAdminRequired] protected function responseDeleteTolerant(Closure $callback, string $token = ''): JSONResponse { if ($token) { $this->session->set('publicPollToken', $token); diff --git a/lib/Controller/CommentApiController.php b/lib/Controller/CommentApiController.php index e50c281d6..8c9d4f54e 100644 --- a/lib/Controller/CommentApiController.php +++ b/lib/Controller/CommentApiController.php @@ -26,6 +26,9 @@ use \OCA\Polls\Db\Comment; use OCA\Polls\Model\Acl; use OCA\Polls\Service\CommentService; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -41,10 +44,10 @@ public function __construct( /** * Read all comments of a poll based on the poll id and return list as array - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => [ 'comments' => $this->commentService->list($this->acl->setPollId($pollId)) @@ -53,10 +56,10 @@ public function list(int $pollId): JSONResponse { /** * Add comment - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function add(int $pollId, string $comment): JSONResponse { return $this->response(fn () => [ 'comment' => $this->commentService->add($comment, $this->acl->setPollId($pollId, Acl::PERMISSION_COMMENT_ADD)) @@ -65,10 +68,10 @@ public function add(int $pollId, string $comment): JSONResponse { /** * Delete comment - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function delete(int $commentId): JSONResponse { return $this->responseDeleteTolerant(fn () => [ 'comment' => $this->deleteComment($commentId) diff --git a/lib/Controller/CommentController.php b/lib/Controller/CommentController.php index e8b53a971..e5557e15a 100644 --- a/lib/Controller/CommentController.php +++ b/lib/Controller/CommentController.php @@ -25,6 +25,7 @@ use OCA\Polls\Model\Acl; use OCA\Polls\Service\CommentService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -42,8 +43,8 @@ public function __construct( /** * Write a new comment to the db and returns the new comment as array - * @NoAdminRequired */ + #[NoAdminRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => [ 'comments' => $this->commentService->list($this->acl->setPollId($pollId)) @@ -52,8 +53,8 @@ public function list(int $pollId): JSONResponse { /** * Write a new comment to the db and returns the new comment as array - * @NoAdminRequired */ + #[NoAdminRequired] public function add(int $pollId, string $message): JSONResponse { return $this->response(fn () => [ 'comment' => $this->commentService->add($message, $this->acl->setPollId($pollId, Acl::PERMISSION_COMMENT_ADD)) @@ -62,8 +63,8 @@ public function add(int $pollId, string $message): JSONResponse { /** * Delete Comment - * @NoAdminRequired */ + #[NoAdminRequired] public function delete(int $commentId): JSONResponse { $comment = $this->commentService->get($commentId); diff --git a/lib/Controller/OptionApiController.php b/lib/Controller/OptionApiController.php index 26a5b140d..019411d42 100644 --- a/lib/Controller/OptionApiController.php +++ b/lib/Controller/OptionApiController.php @@ -24,6 +24,9 @@ namespace OCA\Polls\Controller; use OCA\Polls\Service\OptionService; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -38,20 +41,20 @@ public function __construct( /** * Get all options of given poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => ['options' => $this->optionService->list($pollId)]); } /** * Add a new option - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function add(int $pollId, int $timestamp = 0, string $pollOptionText = '', int $duration = 0): JSONResponse { return $this->responseCreate(fn () => ['option' => $this->optionService->add($pollId, $timestamp, $pollOptionText, $duration)]); } @@ -59,40 +62,40 @@ public function add(int $pollId, int $timestamp = 0, string $pollOptionText = '' /** * Update option - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function update(int $optionId, int $timestamp = 0, string $pollOptionText = '', int $duration = 0): JSONResponse { return $this->response(fn () => ['option' => $this->optionService->update($optionId, $timestamp, $pollOptionText, $duration)]); } /** * Delete option - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function delete(int $optionId): JSONResponse { return $this->responseDeleteTolerant(fn () => ['option' => $this->optionService->delete($optionId)]); } /** * Switch option confirmation - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function confirm(int $optionId): JSONResponse { return $this->response(fn () => ['option' => $this->optionService->confirm($optionId)]); } /** * Set order position for option - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function setOrder(int $optionId, int $order): JSONResponse { return $this->response(fn () => ['option' => $this->optionService->setOrder($optionId, $order)]); } diff --git a/lib/Controller/OptionController.php b/lib/Controller/OptionController.php index 6545c20b3..3bb92505b 100644 --- a/lib/Controller/OptionController.php +++ b/lib/Controller/OptionController.php @@ -25,6 +25,7 @@ use OCA\Polls\Service\CalendarService; use OCA\Polls\Service\OptionService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -42,8 +43,8 @@ public function __construct( /** * Get all options of given poll - * @NoAdminRequired */ + #[NoAdminRequired] public function list(int $pollId): JSONResponse { return $this->response(function () use ($pollId) { return ['options' => $this->optionService->list($pollId)]; @@ -52,72 +53,72 @@ public function list(int $pollId): JSONResponse { /** * Add a new option - * @NoAdminRequired */ + #[NoAdminRequired] public function add(int $pollId, int $timestamp = 0, string $text = '', int $duration = 0): JSONResponse { return $this->responseCreate(fn () => ['option' => $this->optionService->add($pollId, $timestamp, $text, $duration)]); } /** * Add mulitple new option - * @NoAdminRequired */ + #[NoAdminRequired] public function addBulk(int $pollId, string $text = ''): JSONResponse { return $this->responseCreate(fn () => ['options' => $this->optionService->addBulk($pollId, $text)]); } /** * Update option - * @NoAdminRequired */ + #[NoAdminRequired] public function update(int $optionId, int $timestamp, string $text, int $duration): JSONResponse { return $this->response(fn () => ['option' => $this->optionService->update($optionId, $timestamp, $text, $duration)]); } /** * Delete option - * @NoAdminRequired */ + #[NoAdminRequired] public function delete(int $optionId): JSONResponse { return $this->responseDeleteTolerant(fn () => ['option' => $this->optionService->delete($optionId)]); } /** * Switch option confirmation - * @NoAdminRequired */ + #[NoAdminRequired] public function confirm(int $optionId): JSONResponse { return $this->response(fn () => ['option' => $this->optionService->confirm($optionId)]); } /** * Reorder options - * @NoAdminRequired */ + #[NoAdminRequired] public function reorder(int $pollId, array $options): JSONResponse { return $this->response(fn () => ['options' => $this->optionService->reorder($pollId, $options)]); } /** * Reorder options - * @NoAdminRequired */ + #[NoAdminRequired] public function sequence(int $optionId, int $step, string $unit, int $amount): JSONResponse { return $this->response(fn () => ['options' => $this->optionService->sequence($optionId, $step, $unit, $amount)]); } /** * Reorder options - * @NoAdminRequired */ + #[NoAdminRequired] public function shift(int $pollId, int $step, string $unit): JSONResponse { return $this->response(fn () => ['options' => $this->optionService->shift($pollId, $step, $unit)]); } /** * findCalendarEvents - * @NoAdminRequired */ + #[NoAdminRequired] public function findCalendarEvents(int $optionId, string $tz): JSONResponse { return $this->response(fn () => ['events' => $this->calendarService->getEvents($optionId)]); } diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 34d45a107..83c9fa6c1 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -27,6 +27,8 @@ use OCA\Polls\AppConstants; use OCA\Polls\Service\NotificationService; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\TemplateResponse; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; @@ -45,20 +47,17 @@ public function __construct( parent::__construct($appName, $request); } - /** - * @NoAdminRequired - * @NoCSRFRequired - */ + + #[NoAdminRequired] + #[NoCSRFRequired] public function index(): TemplateResponse { Util::addScript(AppConstants::APP_ID, 'polls-main'); $this->eventDispatcher->dispatchTyped(new LoadAdditionalScriptsEvent()); return new TemplateResponse(AppConstants::APP_ID, 'main'); } - /** - * @NoAdminRequired - * @NoCSRFRequired - */ + #[NoAdminRequired] + #[NoCSRFRequired] public function vote(int $id): TemplateResponse { $this->notificationService->removeNotification($id); Util::addScript(AppConstants::APP_ID, 'polls-main'); diff --git a/lib/Controller/PollApiController.php b/lib/Controller/PollApiController.php index cb5f8054e..139c83642 100644 --- a/lib/Controller/PollApiController.php +++ b/lib/Controller/PollApiController.php @@ -29,6 +29,9 @@ use OCA\Polls\Service\PollService; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -44,10 +47,10 @@ public function __construct( /** * Get list of polls - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function list(): JSONResponse { try { return new JSONResponse([AppConstants::APP_ID => $this->pollService->list()], Http::STATUS_OK); @@ -60,10 +63,10 @@ public function list(): JSONResponse { /** * get poll configuration - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function get(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->get($pollId)], Http::STATUS_OK); @@ -76,10 +79,10 @@ public function get(int $pollId): JSONResponse { /** * Add poll - * @NoAdminRequired - * @NoCSRFRequired - * @CORS */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function add(string $type, string $title): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->add($type, $title)], Http::STATUS_CREATED); @@ -90,10 +93,10 @@ public function add(string $type, string $title): JSONResponse { /** * Update poll configuration - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function update(int $pollId, array $poll): JSONResponse { try { $this->acl->setPollId($pollId, Acl::PERMISSION_POLL_EDIT); @@ -111,10 +114,10 @@ public function update(int $pollId, array $poll): JSONResponse { /** * Switch deleted status (move to deleted polls) - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function toggleArchive(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->toggleArchive($pollId)], Http::STATUS_OK); @@ -127,10 +130,10 @@ public function toggleArchive(int $pollId): JSONResponse { /** * Close poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function close(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->close($pollId)], Http::STATUS_OK); @@ -143,10 +146,10 @@ public function close(int $pollId): JSONResponse { /** * Reopen poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function reopen(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->reopen($pollId)], Http::STATUS_OK); @@ -159,10 +162,10 @@ public function reopen(int $pollId): JSONResponse { /** * Delete poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function delete(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->delete($pollId)], Http::STATUS_OK); @@ -175,10 +178,10 @@ public function delete(int $pollId): JSONResponse { /** * Clone poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function clone(int $pollId): JSONResponse { try { return new JSONResponse(['poll' => $this->pollService->clone($pollId)], Http::STATUS_CREATED); @@ -191,11 +194,11 @@ public function clone(int $pollId): JSONResponse { /** * Transfer all polls from one user to another (change owner of poll) - * @CORS - * @NoCSRFRequired * @param string $sourceUser User to transfer polls from * @param string $destinationUser User to transfer polls to */ + #[CORS] + #[NoCSRFRequired] public function transferPolls(string $sourceUser, string $destinationUser): JSONResponse { try { return new JSONResponse(['transferred' => $this->pollService->transferPolls($sourceUser, $destinationUser)], Http::STATUS_CREATED); @@ -206,11 +209,11 @@ public function transferPolls(string $sourceUser, string $destinationUser): JSON /** * Transfer singe poll to another user (change owner of poll) - * @CORS - * @NoCSRFRequired * @param int $pollId Poll to transfer * @param string $destinationUser User to transfer the poll to */ + #[CORS] + #[NoCSRFRequired] public function transferPoll(int $pollId, string $destinationUser): JSONResponse { try { return new JSONResponse(['transferred' => $this->pollService->transferPoll($pollId, $destinationUser)], Http::STATUS_CREATED); @@ -221,10 +224,10 @@ public function transferPoll(int $pollId, string $destinationUser): JSONResponse /** * Collect email addresses from particitipants - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function getParticipantsEmailAddresses(int $pollId): JSONResponse { try { return new JSONResponse($this->pollService->getParticipantsEmailAddresses($pollId), Http::STATUS_OK); @@ -237,10 +240,10 @@ public function getParticipantsEmailAddresses(int $pollId): JSONResponse { /** * Get valid values for configuration options - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function enum(): JSONResponse { return new JSONResponse($this->pollService->getValidEnum(), Http::STATUS_OK); } diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index f4c96946a..88d5a5976 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -29,6 +29,7 @@ use OCA\Polls\Service\MailService; use OCA\Polls\Service\OptionService; use OCA\Polls\Service\PollService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -48,8 +49,8 @@ public function __construct( /** * Get list of polls - * @NoAdminRequired */ + #[NoAdminRequired] public function list(): JSONResponse { return $this->response(function () { $appSettings = new AppSettings; @@ -63,8 +64,8 @@ public function list(): JSONResponse { /** * get complete poll - * @NoAdminRequired */ + #[NoAdminRequired] public function get(int $pollId): JSONResponse { $poll = $this->pollService->get($pollId); $this->acl->setPoll($poll); @@ -76,16 +77,16 @@ public function get(int $pollId): JSONResponse { /** * Add poll - * @NoAdminRequired */ + #[NoAdminRequired] public function add(string $type, string $title): JSONResponse { return $this->responseCreate(fn () => $this->pollService->add($type, $title)); } /** * Update poll configuration - * @NoAdminRequired */ + #[NoAdminRequired] public function update(int $pollId, array $poll): JSONResponse { $this->acl->setPollId($pollId, Acl::PERMISSION_POLL_EDIT); return $this->response(fn () => [ @@ -96,8 +97,8 @@ public function update(int $pollId, array $poll): JSONResponse { /** * Send confirmation mails - * @NoAdminRequired */ + #[NoAdminRequired] public function sendConfirmation(int $pollId): JSONResponse { $this->acl->setPollId($pollId, Acl::PERMISSION_POLL_EDIT); return $this->response(fn () => [ @@ -107,16 +108,16 @@ public function sendConfirmation(int $pollId): JSONResponse { /** * Switch deleted status (move to deleted polls) - * @NoAdminRequired */ + #[NoAdminRequired] public function toggleArchive(int $pollId): JSONResponse { return $this->response(fn () => $this->pollService->toggleArchive($pollId)); } /** * Delete poll - * @NoAdminRequired */ + #[NoAdminRequired] public function delete(int $pollId): JSONResponse { return $this->responseDeleteTolerant(fn () => $this->pollService->delete($pollId)); @@ -124,8 +125,8 @@ public function delete(int $pollId): JSONResponse { /** * Close poll - * @NoAdminRequired */ + #[NoAdminRequired] public function close(int $pollId): JSONResponse { return $this->response(fn () => [ 'poll' => $this->pollService->close($pollId), @@ -135,8 +136,8 @@ public function close(int $pollId): JSONResponse { /** * Reopen poll - * @NoAdminRequired */ + #[NoAdminRequired] public function reopen(int $pollId): JSONResponse { return $this->response(fn () => [ 'poll' => $this->pollService->reopen($pollId), @@ -146,8 +147,8 @@ public function reopen(int $pollId): JSONResponse { /** * Clone poll - * @NoAdminRequired */ + #[NoAdminRequired] public function clone(int $pollId): JSONResponse { return $this->response(fn () => $this->clonePoll($pollId)); } @@ -167,8 +168,8 @@ public function transferPolls(string $sourceUser, string $targetUser): JSONRespo /** * Collect email addresses from particitipants - * @NoAdminRequired */ + #[NoAdminRequired] public function getParticipantsEmailAddresses(int $pollId): JSONResponse { return $this->response(fn () => $this->pollService->getParticipantsEmailAddresses($pollId)); } diff --git a/lib/Controller/PreferencesController.php b/lib/Controller/PreferencesController.php index 47d7a7d67..eb159ae3d 100644 --- a/lib/Controller/PreferencesController.php +++ b/lib/Controller/PreferencesController.php @@ -26,6 +26,8 @@ use OCA\Polls\Service\CalendarService; use OCA\Polls\Service\PreferencesService; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -45,17 +47,17 @@ public function __construct( /** * Read all preferences - * @NoAdminRequired - * @NoCSRFRequired */ + #[NoAdminRequired] + #[NoCSRFRequired] public function get(): JSONResponse { return $this->response(fn () => $this->preferencesService->get()); } /** * Write preferences - * @NoAdminRequired */ + #[NoAdminRequired] public function write(array $preferences): JSONResponse { if (!$this->userSession->isLoggedIn()) { return new JSONResponse([], Http::STATUS_OK); @@ -65,9 +67,9 @@ public function write(array $preferences): JSONResponse { /** * Read all preferences - * @NoAdminRequired - * @NoCSRFRequired */ + #[NoAdminRequired] + #[NoCSRFRequired] public function getCalendars(): JSONResponse { return new JSONResponse(['calendars' => $this->calendarService->getCalendars()], Http::STATUS_OK); } diff --git a/lib/Controller/PublicController.php b/lib/Controller/PublicController.php index 4521a02da..b0b9ed0a9 100644 --- a/lib/Controller/PublicController.php +++ b/lib/Controller/PublicController.php @@ -34,6 +34,7 @@ use OCA\Polls\Service\SystemService; use OCA\Polls\Service\VoteService; use OCA\Polls\Service\WatchService; +use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\AppFramework\Http\TemplateResponse; @@ -65,10 +66,9 @@ public function __construct( } /** - * @NoCSRFRequired - * @PublicPage * @return TemplateResponse|PublicTemplateResponse */ + #[PublicPage] public function votePage(string $token) { Util::addScript(AppConstants::APP_ID, 'polls-main'); if ($this->userSession->isLoggedIn()) { @@ -82,8 +82,8 @@ public function votePage(string $token) { /** * get complete poll via token - * @PublicPage */ + #[PublicPage] public function getPoll(string $token): JSONResponse { $this->acl->setToken($token); @@ -95,8 +95,8 @@ public function getPoll(string $token): JSONResponse { /** * Watch poll for updates - * @PublicPage */ + #[PublicPage] public function watchPoll(string $token, ?int $offset): JSONResponse { return $this->responseLong(fn () => [ 'updates' => $this->watchService->watchUpdates($this->acl->setToken($token)->getPollId(), $offset) @@ -105,8 +105,8 @@ public function watchPoll(string $token, ?int $offset): JSONResponse { /** * Get share - * @PublicPage */ + #[PublicPage] public function getShare(string $token): JSONResponse { $validateShareType = true; $publicRequest = true; @@ -117,8 +117,8 @@ public function getShare(string $token): JSONResponse { /** * Get votes - * @PublicPage */ + #[PublicPage] public function getVotes(string $token): JSONResponse { $this->acl->setToken($token); @@ -129,8 +129,8 @@ public function getVotes(string $token): JSONResponse { /** * Delete user's votes - * @PublicPage */ + #[PublicPage] public function deleteUser(string $token): JSONResponse { return $this->response(fn () => [ 'deleted' => $this->voteService->delete(acl: $this->acl->setToken($token, Acl::PERMISSION_VOTE_EDIT)) @@ -139,8 +139,8 @@ public function deleteUser(string $token): JSONResponse { /** * Get options - * @PublicPage */ + #[PublicPage] public function getOptions(string $token): JSONResponse { return $this->response(fn () => [ 'options' => $this->optionService->list(acl: $this->acl->setToken($token)) @@ -149,8 +149,8 @@ public function getOptions(string $token): JSONResponse { /** * Add options - * @PublicPage */ + #[PublicPage] public function addOption(string $token, int $timestamp = 0, string $text = '', int $duration = 0): JSONResponse { return $this->responseCreate(fn () => [ 'option' => $this->optionService->add( @@ -164,8 +164,8 @@ public function addOption(string $token, int $timestamp = 0, string $text = '', /** * Delete option - * @PublicPage */ + #[PublicPage] public function deleteOption(string $token, int $optionId): JSONResponse { return $this->responseDeleteTolerant(fn () => [ 'option' => $this->optionService->delete($optionId, $this->acl->setToken($token, Acl::PERMISSION_POLL_VIEW)) @@ -174,8 +174,8 @@ public function deleteOption(string $token, int $optionId): JSONResponse { /** * Set Vote - * @PublicPage */ + #[PublicPage] public function setVote(int $optionId, string $setTo, string $token): JSONResponse { return $this->response(fn () => [ 'vote' => $this->voteService->set($optionId, $setTo, $this->acl->setToken($token, Acl::PERMISSION_VOTE_EDIT)) @@ -184,8 +184,8 @@ public function setVote(int $optionId, string $setTo, string $token): JSONRespon /** * Get Comments - * @PublicPage */ + #[PublicPage] public function getComments(string $token): JSONResponse { return $this->response(fn () => [ 'comments' => $this->commentService->list($this->acl->setToken($token)) @@ -194,8 +194,8 @@ public function getComments(string $token): JSONResponse { /** * Write a new comment to the db and returns the new comment as array - * @PublicPage */ + #[PublicPage] public function addComment(string $token, string $message): JSONResponse { return $this->response(fn () => [ 'comment' => $this->commentService->add($message, $this->acl->setToken($token, Acl::PERMISSION_COMMENT_ADD)) @@ -204,8 +204,8 @@ public function addComment(string $token, string $message): JSONResponse { /** * Delete Comment - * @PublicPage */ + #[PublicPage] public function deleteComment(int $commentId, string $token): JSONResponse { $comment = $this->commentService->get($commentId); return $this->responseDeleteTolerant(fn () => [ @@ -215,8 +215,8 @@ public function deleteComment(int $commentId, string $token): JSONResponse { /** * Get subscription status - * @PublicPage */ + #[PublicPage] public function getSubscription(string $token): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->get($this->acl->setToken($token)) @@ -225,8 +225,8 @@ public function getSubscription(string $token): JSONResponse { /** * subscribe - * @PublicPage */ + #[PublicPage] public function subscribe(string $token): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->set(true, $this->acl->setToken($token)) @@ -235,8 +235,8 @@ public function subscribe(string $token): JSONResponse { /** * Unsubscribe - * @PublicPage */ + #[PublicPage] public function unsubscribe(string $token): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->set(false, $this->acl->setToken($token)) @@ -247,8 +247,8 @@ public function unsubscribe(string $token): JSONResponse { * Validate it the user name is reservrd * return false, if this username already exists as a user or as * a participant of the poll - * @PublicPage */ + #[PublicPage] public function validatePublicUsername(string $userName, string $token): JSONResponse { return $this->response(fn () => [ 'result' => $this->systemService->validatePublicUsername($userName, $this->shareService->get($token)), 'name' => $userName @@ -257,8 +257,8 @@ public function validatePublicUsername(string $userName, string $token): JSONRes /** * Validate email address (simple validation) - * @PublicPage */ + #[PublicPage] public function validateEmailAddress(string $emailAddress): JSONResponse { return $this->response(fn () => [ 'result' => $this->systemService->validateEmailAddress($emailAddress), 'emailAddress' => $emailAddress @@ -267,8 +267,8 @@ public function validateEmailAddress(string $emailAddress): JSONResponse { /** * Change displayName - * @PublicPage */ + #[PublicPage] public function setDisplayName(string $token, string $displayName): JSONResponse { return $this->response(fn () => [ 'share' => $this->shareService->setDisplayname($this->shareService->get($token), $displayName) @@ -278,8 +278,8 @@ public function setDisplayName(string $token, string $displayName): JSONResponse /** * Set EmailAddress - * @PublicPage */ + #[PublicPage] public function setEmailAddress(string $token, string $emailAddress = ''): JSONResponse { return $this->response(fn () => [ 'share' => $this->shareService->setEmailAddress($this->shareService->get($token), $emailAddress, true) @@ -288,8 +288,8 @@ public function setEmailAddress(string $token, string $emailAddress = ''): JSONR /** * Set EmailAddress - * @PublicPage */ + #[PublicPage] public function deleteEmailAddress(string $token): JSONResponse { return $this->response(fn () => [ 'share' => $this->shareService->deleteEmailAddress($this->shareService->get($token)) @@ -299,8 +299,8 @@ public function deleteEmailAddress(string $token): JSONResponse { /** * Create a personal share from a public share * or update an email share with the username - * @PublicPage */ + #[PublicPage] public function register(string $token, string $userName, string $emailAddress = '', string $timeZone = ''): JSONResponse { $publicShare = $this->shareService->get($token); $personalShare = $this->shareService->register($publicShare, $userName, $emailAddress, $timeZone); @@ -312,8 +312,8 @@ public function register(string $token, string $userName, string $emailAddress = /** * Sent invitation mails for a share * Additionally send notification via notifications - * @PublicPage */ + #[PublicPage] public function resendInvitation(string $token): JSONResponse { $share = $this->shareService->get($token); return $this->response(fn () => [ diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index ba2253eb7..4652e4ad2 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -24,6 +24,8 @@ namespace OCA\Polls\Controller; use OCA\Polls\Service\SettingsService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\PublicPage; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -40,9 +42,9 @@ public function __construct( /** * Read app settings - * @PublicPage - * @NoAdminRequired */ + #[NoAdminRequired] + #[PublicPage] public function getAppSettings(): JSONResponse { return $this->response(fn () => ['appSettings' => $this->settingsService->getAppSettings()]); } diff --git a/lib/Controller/ShareApiController.php b/lib/Controller/ShareApiController.php index 759ff98fa..b310e3158 100644 --- a/lib/Controller/ShareApiController.php +++ b/lib/Controller/ShareApiController.php @@ -25,6 +25,9 @@ use OCA\Polls\Service\MailService; use OCA\Polls\Service\ShareService; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -40,70 +43,70 @@ public function __construct( /** * Read all shares of a poll based on the poll id and return list as array - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => ['shares' => $this->shareService->list($pollId)]); } /** * Get share by token - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function get(string $token): JSONResponse { return $this->response(fn () => ['share' => $this->shareService->get($token)]); } /** * Add share - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function add(int $pollId, string $type, string $userId = ''): JSONResponse { return $this->responseCreate(fn () => ['share' => $this->shareService->add($pollId, $type, $userId)]); } /** * Delete share - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function delete(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->delete(token: $token)]); } /** * Lock share - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function lock(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->lock(token: $token)]); } /** * Unlock share - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function unlock(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->unlock(token: $token)]); } /** * Sent invitation mails for a share - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function sendInvitation(string $token): JSONResponse { $share = $this->shareService->get($token); return $this->response(fn () => [ diff --git a/lib/Controller/ShareController.php b/lib/Controller/ShareController.php index 157182ce9..6fd0b7b88 100644 --- a/lib/Controller/ShareController.php +++ b/lib/Controller/ShareController.php @@ -26,6 +26,7 @@ use OCA\Polls\Db\Share; use OCA\Polls\Service\ShareService; use OCA\Polls\Service\UserService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -43,42 +44,40 @@ public function __construct( /** * List shares - * @NoAdminRequired - * - * @return JSONResponse */ + #[NoAdminRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => ['shares' => $this->shareService->list($pollId)]); } /** * Add share - * @NoAdminRequired */ + #[NoAdminRequired] public function add(int $pollId, string $type, string $userId = '', string $displayName = '', string $emailAddress = ''): JSONResponse { return $this->responseCreate(fn () => ['share' => $this->shareService->add($pollId, $type, $userId, $displayName, $emailAddress)]); } /** * Convert user to poll admin - * @NoAdminRequired */ + #[NoAdminRequired] public function userToAdmin(string $token): JSONResponse { return $this->responseCreate(fn () => ['share' => $this->shareService->setType($token, Share::TYPE_ADMIN)]); } /** * Change the contraints for email addresses in public polls - * @NoAdminRequired */ + #[NoAdminRequired] public function setPublicPollEmail(string $token, string $value): JSONResponse { return $this->response(fn () => ['share' => $this->shareService->setPublicPollEmail($token, $value)]); } /** * Change the contraints for email addresses in public polls - * @NoAdminRequired */ + #[NoAdminRequired] public function setLabel(string $token, string $label = ''): JSONResponse { return $this->response(fn () => [ 'share' => $this->shareService->setDisplayName($this->shareService->get($token), $label) @@ -87,16 +86,16 @@ public function setLabel(string $token, string $label = ''): JSONResponse { /** * Convert poll admin to user - * @NoAdminRequired */ + #[NoAdminRequired] public function adminToUser(string $token): JSONResponse { return $this->responseCreate(fn () => ['share' => $this->shareService->setType($token, Share::TYPE_USER)]); } /** * Set email address - * @NoAdminRequired */ + #[NoAdminRequired] public function setEmailAddress(string $token, string $emailAddress = ''): JSONResponse { return $this->response(fn () => [ 'share' => $this->shareService->setEmailAddress($this->shareService->get($token), @@ -106,8 +105,8 @@ public function setEmailAddress(string $token, string $emailAddress = ''): JSONR /** * Delete share - * @NoAdminRequired */ + #[NoAdminRequired] public function delete(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->delete(token: $token)]); @@ -115,8 +114,8 @@ public function delete(string $token): JSONResponse { /** * Delete share - * @NoAdminRequired */ + #[NoAdminRequired] public function lock(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->lock(token: $token)]); @@ -124,8 +123,8 @@ public function lock(string $token): JSONResponse { /** * Delete share - * @NoAdminRequired */ + #[NoAdminRequired] public function unlock(string $token): JSONResponse { return $this->responseDeleteTolerant(fn () => ['share' => $this->shareService->unlock(token: $token)]); @@ -134,8 +133,8 @@ public function unlock(string $token): JSONResponse { /** * Send invitation mails for a share * Additionally send notification via notifications - * @NoAdminRequired */ + #[NoAdminRequired] public function sendInvitation(string $token): JSONResponse { $share = $this->shareService->get($token); return $this->response(fn () => [ @@ -147,8 +146,8 @@ public function sendInvitation(string $token): JSONResponse { /** * Send all invitation mails for a share and resolve groups * Additionally send notification via notifications - * @NoAdminRequired */ + #[NoAdminRequired] public function sendAllInvitations(int $pollId): JSONResponse { return $this->response(fn () => [ 'poll' => $pollId, @@ -158,8 +157,8 @@ public function sendAllInvitations(int $pollId): JSONResponse { /** * resolve contact group to individual shares - * @NoAdminRequired */ + #[NoAdminRequired] public function resolveGroup(string $token): JSONResponse { return $this->response(fn () => [ 'shares' => $this->shareService->resolveGroup($token) diff --git a/lib/Controller/SubscriptionApiController.php b/lib/Controller/SubscriptionApiController.php index c393cc29d..06298ab4d 100644 --- a/lib/Controller/SubscriptionApiController.php +++ b/lib/Controller/SubscriptionApiController.php @@ -27,6 +27,9 @@ use OCA\Polls\Model\Acl; use OCA\Polls\Service\SubscriptionService; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -42,10 +45,10 @@ public function __construct( /** * Get subscription status - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function get(int $pollId): JSONResponse { try { return new JSONResponse([ @@ -59,10 +62,10 @@ public function get(int $pollId): JSONResponse { /** * Subscribe to poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function subscribe(int $pollId): JSONResponse { try { $this->subscriptionService->set(true, $this->acl->setPollId($pollId)); @@ -77,10 +80,10 @@ public function subscribe(int $pollId): JSONResponse { /** * Unsubscribe from poll - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function unsubscribe(int $pollId): JSONResponse { try { $this->subscriptionService->set(false, $this->acl->setPollId($pollId)); diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php index e37fefc17..253ec59bf 100644 --- a/lib/Controller/SubscriptionController.php +++ b/lib/Controller/SubscriptionController.php @@ -25,6 +25,7 @@ use OCA\Polls\Model\Acl; use OCA\Polls\Service\SubscriptionService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -42,8 +43,8 @@ public function __construct( /** * Get subscription status - * @NoAdminRequired */ + #[NoAdminRequired] public function get(int $pollId): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->get($this->acl->setPollId($pollId)) @@ -52,8 +53,8 @@ public function get(int $pollId): JSONResponse { /** * subscribe - * @NoAdminRequired */ + #[NoAdminRequired] public function subscribe(int $pollId): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->set(true, $this->acl->setPollId($pollId)) @@ -62,8 +63,8 @@ public function subscribe(int $pollId): JSONResponse { /** * Unsubscribe - * @NoAdminRequired */ + #[NoAdminRequired] public function unsubscribe(int $pollId): JSONResponse { return $this->response(fn () => [ 'subscribed' => $this->subscriptionService->set(false, $this->acl->setPollId($pollId)) diff --git a/lib/Controller/SystemController.php b/lib/Controller/SystemController.php index 0a9897958..0350ca93a 100644 --- a/lib/Controller/SystemController.php +++ b/lib/Controller/SystemController.php @@ -25,6 +25,7 @@ use OCA\Polls\Service\SystemService; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -41,8 +42,8 @@ public function __construct( /** * Get a combined list of NC users, groups and contacts - * @NoAdminRequired */ + #[NoAdminRequired] public function userSearch(string $query = ''): JSONResponse { return new JSONResponse(['siteusers' => $this->systemService->getSiteUsersAndGroups( $query)], Http::STATUS_OK); diff --git a/lib/Controller/VoteApiController.php b/lib/Controller/VoteApiController.php index c90fab4d0..af36deb0c 100644 --- a/lib/Controller/VoteApiController.php +++ b/lib/Controller/VoteApiController.php @@ -27,6 +27,9 @@ use OCA\Polls\Service\VoteService; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Attribute\CORS; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; @@ -41,10 +44,10 @@ public function __construct( /** * Read all votes of a poll based on the poll id and return list as array - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function list(int $pollId): JSONResponse { try { return new JSONResponse(['votes' => $this->voteService->list($pollId)], Http::STATUS_OK); @@ -57,10 +60,10 @@ public function list(int $pollId): JSONResponse { /** * Set vote answer - * @NoAdminRequired - * @CORS - * @NoCSRFRequired */ + #[CORS] + #[NoAdminRequired] + #[NoCSRFRequired] public function set(int $optionId, string $answer): JSONResponse { try { return new JSONResponse(['vote' => $this->voteService->set($optionId, $answer)], Http::STATUS_OK); diff --git a/lib/Controller/VoteController.php b/lib/Controller/VoteController.php index ab65c0eeb..a5875cf5f 100644 --- a/lib/Controller/VoteController.php +++ b/lib/Controller/VoteController.php @@ -24,6 +24,8 @@ namespace OCA\Polls\Controller; use OCA\Polls\Service\VoteService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -39,27 +41,27 @@ public function __construct( } /** - * set - * @NoAdminRequired - * @NoCSRFRequired + * list votes per poll */ + #[NoAdminRequired] + #[NoCSRFRequired] public function list(int $pollId): JSONResponse { return $this->response(fn () => ['votes' => $this->voteService->list($pollId)]); } /** - * set - * @NoAdminRequired - * @NoCSRFRequired + * set vote answer */ + #[NoAdminRequired] + #[NoCSRFRequired] public function set(int $optionId, string $setTo): JSONResponse { return $this->response(fn () => ['vote' => $this->voteService->set($optionId, $setTo)]); } /** * Remove user from poll - * @NoAdminRequired */ + #[NoAdminRequired] public function delete(int $pollId, string $userId = ''): JSONResponse { return $this->response(fn () => ['deleted' => $this->voteService->delete($pollId, $userId)]); } diff --git a/lib/Controller/WatchController.php b/lib/Controller/WatchController.php index e9f010652..0d80d3596 100644 --- a/lib/Controller/WatchController.php +++ b/lib/Controller/WatchController.php @@ -24,6 +24,8 @@ namespace OCA\Polls\Controller; use OCA\Polls\Service\WatchService; +use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\NoCSRFRequired; use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; use OCP\ISession; @@ -40,9 +42,9 @@ public function __construct( /** * Watch poll for updates - * @NoAdminRequired - * @NoCSRFRequired */ + #[NoAdminRequired] + #[NoCSRFRequired] public function watchPoll(int $pollId, ?int $offset): JSONResponse { return $this->responseLong(fn () => ['updates' => $this->watchService->watchUpdates($pollId, $offset)]); } diff --git a/psalm-baseline.xml b/psalm-baseline.xml index a9d5fb254..2f455e044 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,2 +1,9 @@ - + + + + circle]]> + CirclesCircle + + +