Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-26 17:30:41 +0300
committerJoas Schilling <coding@schilljs.com>2022-08-26 17:30:41 +0300
commit9ddae531db6f80df958ff9a263e08ebf3a990bf0 (patch)
treef048e2cb62c80b0f217ea96157eeff85837f0876
parent46a2326c799a5fd876bbe0c65a74a206749823f7 (diff)
Don't allow to close polls twicebugfix/noid/dont-allow-to-close-polls-twice
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--docs/poll.md1
-rw-r--r--lib/Controller/PollController.php4
-rw-r--r--tests/integration/features/chat/poll.feature1
3 files changed, 6 insertions, 0 deletions
diff --git a/docs/poll.md b/docs/poll.md
index ca87b413d..758377b0f 100644
--- a/docs/poll.md
+++ b/docs/poll.md
@@ -77,6 +77,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
* Response:
- Status code:
+ `200 OK`
+ + `400 Bad Request` When the poll is already closed
+ `403 Forbidden` When the participant is not the author of the poll or a moderator
+ `404 Not Found` When the conversation could not be found for the participant
+ `404 Not Found` When the poll id could not be found in the conversation
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php
index 3d89ad5c9..5b0c183dc 100644
--- a/lib/Controller/PollController.php
+++ b/lib/Controller/PollController.php
@@ -202,6 +202,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);
+ }
+
$poll->setStatus(Poll::STATUS_CLOSED);
try {
diff --git a/tests/integration/features/chat/poll.feature b/tests/integration/features/chat/poll.feature
index 46a90eb3a..d7acc1692 100644
--- a/tests/integration/features/chat/poll.feature
+++ b/tests/integration/features/chat/poll.feature
@@ -382,6 +382,7 @@ Feature: chat/poll
| actorDisplayName | participant1-displayname |
| status | closed |
| votedSelf | [0] |
+ Then user "participant1" closes poll "What is the question?" in room "room" with 400
Then user "participant1" sees the following system messages in room "room" with 200 (v1)
| room | actorType | actorId | actorDisplayName | systemMessage |
| room | users | participant1 | participant1-displayname | poll_closed |