diff --git a/docs/poll.md b/docs/poll.md index 758377b0f99..8d41e105f21 100644 --- a/docs/poll.md +++ b/docs/poll.md @@ -18,6 +18,7 @@ Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1` * Response: - Status code: + `201 Created` + + `400 Bad Request` When the room is a one-to-one conversation + `400 Bad Request` When the question or the options were too long or invalid (not strings) + `403 Forbidden` When the conversation is read-only + `403 Forbidden` When the actor does not have chat permissions diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php index 15d395bd7cb..8deb0ead29d 100644 --- a/lib/Controller/PollController.php +++ b/lib/Controller/PollController.php @@ -30,6 +30,7 @@ use OCA\Talk\Exceptions\WrongPermissionsException; use OCA\Talk\Model\Poll; use OCA\Talk\Model\Vote; +use OCA\Talk\Room; use OCA\Talk\Service\AttachmentService; use OCA\Talk\Service\PollService; use OCP\AppFramework\Db\DoesNotExistException; @@ -76,6 +77,10 @@ public function __construct(string $appName, * @return DataResponse */ public function createPoll(string $question, array $options, int $resultMode, int $maxVotes): DataResponse { + if ($this->room->getType() === Room::TYPE_ONE_TO_ONE) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + $attendee = $this->participant->getAttendee(); try { $poll = $this->pollService->createPoll( diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue index 3693a0ae6db..2d35e26665e 100644 --- a/src/components/NewMessageForm/NewMessageForm.vue +++ b/src/components/NewMessageForm/NewMessageForm.vue @@ -357,8 +357,7 @@ export default { }, canCreatePoll() { - // FIXME - return !this.isOneToOne + return !this.isOneToOne && !this.noChatPermission }, attachmentFolderFreeSpace() { diff --git a/tests/integration/features/chat/poll.feature b/tests/integration/features/chat/poll.feature index ab77b2194c3..1e56b1cbb0c 100644 --- a/tests/integration/features/chat/poll.feature +++ b/tests/integration/features/chat/poll.feature @@ -233,7 +233,7 @@ Feature: chat/poll | votedSelf | not voted | | details | {} | - Scenario: Non-moderators can note create polls without chat permission + Scenario: Non-moderators can not create polls without chat permission Given user "participant1" creates room "room" (v4) | roomType | 2 | | roomName | room | @@ -590,6 +590,16 @@ Feature: chat/poll | resultMode | public | | maxVotes | unlimited | + Scenario: Can not poll in one-to-one + Given user "participant1" creates room "room" (v4) + | roomType | 1 | + | invite | participant2 | + When user "participant1" creates a poll in room "room" with 400 + | question | Can I poll in one-to-one? | + | options | ["No","Nope"] | + | resultMode | public | + | maxVotes | unlimited | + Scenario: Deleting a user neutralizes their details Given user "participant1" creates room "room" (v4) | roomType | 2 |