diff options
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/PollController.php | 12 | ||||
-rw-r--r-- | lib/Controller/ShareController.php | 24 |
2 files changed, 32 insertions, 4 deletions
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index a564fe40..494cb59a 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -151,8 +151,15 @@ class PollController extends Controller { } try { - $shares = $this->shareService->list($pollId, $token); + if ($token) { + $share = $this->shareService->get($token); + $shares = []; + } else { + $share = null; + $shares = $this->shareService->list($pollId, $token); + } } catch (Exception $e) { + $share = null; $shares = []; } @@ -161,8 +168,9 @@ class PollController extends Controller { 'poll' => $poll, 'comments' => $comments, 'options' => $options, + 'share' => $share, 'shares' => $shares, - 'votes' => $votes + 'votes' => $votes, ], Http::STATUS_OK); } diff --git a/lib/Controller/ShareController.php b/lib/Controller/ShareController.php index 9cd5f554..0c50b4c7 100644 --- a/lib/Controller/ShareController.php +++ b/lib/Controller/ShareController.php @@ -94,6 +94,26 @@ class ShareController extends Controller { * @param string $userEmail * @return DataResponse */ + public function get($token) { + try { + return new DataResponse(['share' => $this->shareService->get($token)], Http::STATUS_CREATED); + } catch (NotAuthorizedException $e) { + return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); + } catch (\Exception $e) { + return new DataResponse($e, Http::STATUS_CONFLICT); + } + } + + /** + * Add share + * @NoAdminRequired + * @param int $pollId + * @param int $pollId + * @param string $type + * @param string $userId + * @param string $userEmail + * @return DataResponse + */ public function setEmailAddress($token, $userEmail) { try { return new DataResponse(['share' => $this->shareService->setEmailAddress($token, $userEmail)], Http::STATUS_OK); @@ -115,10 +135,10 @@ class ShareController extends Controller { * @param string $userName * @return DataResponse */ - public function personal($token, $userName) { + public function personal($token, $userName, $emailAddress = '') { try { - return new DataResponse($this->shareService->personal($token, $userName), Http::STATUS_CREATED); + return new DataResponse($this->shareService->personal($token, $userName, $emailAddress), Http::STATUS_CREATED); } catch (NotAuthorizedException $e) { return new DataResponse(['error' => $e->getMessage()], $e->getStatus()); } catch (InvalidUsername $e) { |