diff options
author | dartcafe <github@dartcafe.de> | 2020-08-07 23:47:10 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-08-07 23:47:10 +0300 |
commit | dad6b97a38348f620d20e5d20108a628269645ee (patch) | |
tree | c93f41df133cf0e6ac9f67557e05b065fe57f46e /lib/Controller | |
parent | db579c72b6315944e6e6b2170acc17f973f8e7f8 (diff) |
public subscription for shares with mail address
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/PollController.php | 18 | ||||
-rw-r--r-- | lib/Controller/SubscriptionController.php | 10 |
2 files changed, 13 insertions, 15 deletions
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index 04445482..a564fe40 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -121,14 +121,10 @@ class PollController extends Controller { * @return DataResponse */ public function get($pollId, $token) { + try { - if ($token) { - $poll = $this->pollService->getByToken($token); - $acl = $this->acl->setToken($token); - } else { - $poll = $this->pollService->get($pollId); - $acl = $this->acl->setPollId($pollId); - } + $acl = $this->acl->set($pollId, $token); + $poll = $this->pollService->get($pollId, $token); } catch (DoesNotExistException $e) { return new DataResponse(['error' => 'Not found'], Http::STATUS_NOT_FOUND); @@ -137,25 +133,25 @@ class PollController extends Controller { } try { - $comments = $this->commentService->list($poll->getId(), $token); + $comments = $this->commentService->list($pollId, $token); } catch (Exception $e) { $comments = []; } try { - $options = $this->optionService->list($poll->getId(), $token); + $options = $this->optionService->list($pollId, $token); } catch (Exception $e) { $options = []; } try { - $votes = $this->voteService->list($poll->getId(), $token); + $votes = $this->voteService->list($pollId, $token); } catch (Exception $e) { $votes = []; } try { - $shares = $this->shareService->list($poll->getId()); + $shares = $this->shareService->list($pollId, $token); } catch (Exception $e) { $shares = []; } diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php index f2517237..ea1e9e49 100644 --- a/lib/Controller/SubscriptionController.php +++ b/lib/Controller/SubscriptionController.php @@ -57,15 +57,16 @@ class SubscriptionController extends Controller { /** * Get subscription status + * @PublicPage * @NoAdminRequired * @param int $pollId * @return DataResponse * @throws DoesNotExistException * @throws NotAuthorizedException */ - public function get($pollId) { + public function get($pollId, $token) { try { - return new DataResponse($this->subscriptionService->get($pollId), Http::STATUS_OK); + return new DataResponse($this->subscriptionService->get($pollId, $token), Http::STATUS_OK); } catch (NotAuthorizedException $e) { return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); } catch (DoesNotExistException $e) { @@ -75,15 +76,16 @@ class SubscriptionController extends Controller { /** * Switch subscription status + * @PublicPage * @NoAdminRequired * @param int $pollId * @param int $subscribed * @return DataResponse * @throws NotAuthorizedException */ - public function set($pollId, $subscribed) { + public function set($pollId, $token, $subscribed) { try { - return new DataResponse($this->subscriptionService->set($pollId, $subscribed), Http::STATUS_OK); + return new DataResponse($this->subscriptionService->set($pollId, $token, $subscribed), Http::STATUS_OK); } catch (NotAuthorizedException $e) { return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); } |