diff options
author | dartcafe <github@dartcafe.de> | 2020-08-11 22:56:26 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2020-08-11 22:56:26 +0300 |
commit | a7d96426e31d8853a2def37c587b27fe1c1ff3f6 (patch) | |
tree | 35b9333582f1ad69f97dfc8c7af129a17a4de3d2 /lib/Controller | |
parent | dad6b97a38348f620d20e5d20108a628269645ee (diff) |
user can add own email address
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) { |