Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/poll.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/Controller/PollController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/components/NewMessageForm/NewMessageForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ export default {
},

canCreatePoll() {
// FIXME
return !this.isOneToOne
return !this.isOneToOne && !this.noChatPermission
},

attachmentFolderFreeSpace() {
Expand Down
12 changes: 11 additions & 1 deletion tests/integration/features/chat/poll.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down