diff options
author | Joas Schilling <coding@schilljs.com> | 2022-06-13 14:56:01 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-06-13 14:56:01 +0300 |
commit | 55bb6c066cb4132bc083079fc84a5310185f39e2 (patch) | |
tree | ce6bec4bde169002f9099b58af3d7860c2839ae5 | |
parent | ec24253ca490f58be16d2b5b08ab6213da6918cb (diff) |
Don't allow updating/voting after closingfeature/noid/simple-polls
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Controller/PollController.php | 4 | ||||
-rw-r--r-- | tests/integration/features/chat/poll.feature | 17 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index 9ed4c305f..fdf6277d3 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -155,6 +155,10 @@ class PollController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_NOT_FOUND); } + if ($poll->getStatus() === Poll::STATUS_CLOSED) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + try { $votedSelf = $this->pollService->votePoll($this->participant, $poll, $optionIds); } catch (\RuntimeException $e) { diff --git a/tests/integration/features/chat/poll.feature b/tests/integration/features/chat/poll.feature index 4bac34846..9166d6850 100644 --- a/tests/integration/features/chat/poll.feature +++ b/tests/integration/features/chat/poll.feature @@ -97,7 +97,7 @@ Feature: chat/poll | votedSelf | not voted | | details | [{"actorType":"users","actorId":"participant1","actorDisplayName":"participant1-displayname","optionId":1}] | - Scenario: Participants can update their votes + Scenario: Participants can update their votes but only while open Given user "participant1" creates room "room" (v4) | roomType | 2 | | roomName | room | @@ -132,6 +132,21 @@ Feature: chat/poll | actorDisplayName | participant1-displayname | | status | open | | votedSelf | [1] | + Then user "participant1" closes poll "What is the question?" in room "room" with 200 + | id | POLL_ID(What is the question?) | + | question | What is the question? | + | options | ["Where are you?","How much is the fish?"] | + | votes | {"1":1} | + | numVoters | 1 | + | resultMode | public | + | maxVotes | unlimited | + | actorType | users | + | actorId | participant1 | + | actorDisplayName | participant1-displayname | + | status | closed | + | votedSelf | [1] | + | details | [{"actorType":"users","actorId":"participant1","actorDisplayName":"participant1-displayname","optionId":1}] | + Then user "participant1" votes for options "[0]" on poll "What is the question?" in room "room" with 400 Scenario: Participants can only vote for valid options Given user "participant1" creates room "room" (v4) |