Skip to content

Commit

Permalink
Merge pull request #7917 from nextcloud/bugfix/7476/flow-and-chat-per…
Browse files Browse the repository at this point in the history
…missions

Fix flow and chat permissions
  • Loading branch information
nickvergessen authored Sep 15, 2022
2 parents 99153c0 + add1d45 commit c4e4b84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager as TalkManager;
use OCA\Talk\Model\Attendee;
use OCA\Talk\Participant;
use OCA\Talk\Room;
use OCP\EventDispatcher\Event;
Expand Down Expand Up @@ -116,7 +117,17 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
}

$room = $this->getRoom($token, $uid);
if ($room->getReadOnly() !== Room::READ_WRITE) {
// Ignore conversation because it is locked
continue;
}

$participant = $this->getParticipant($uid, $room);
if (!($participant->getPermissions() & Attendee::PERMISSIONS_CHAT)) {
// Ignore conversation because the user has no permissions
continue;
}

$this->chatManager->sendMessage(
$room,
$participant,
Expand Down
3 changes: 2 additions & 1 deletion src/views/FlowPostToConversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import NcMultiselect from '@nextcloud/vue/dist/Components/NcMultiselect.js'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import { FLOW, CONVERSATION } from '../constants.js'
import { FLOW, CONVERSATION, PARTICIPANT } from '../constants.js'
export default {
name: 'FlowPostToConversation',
Expand Down Expand Up @@ -80,6 +80,7 @@ export default {
axios.get(generateOcsUrl('/apps/spreed/api/v4/room')).then((response) => {
this.roomOptions = response.data.ocs.data.filter(function(room) {
return room.readOnly === CONVERSATION.STATE.READ_WRITE
&& (room.permissions & PARTICIPANT.PERMISSIONS.CHAT) !== 0
})
})
},
Expand Down

0 comments on commit c4e4b84

Please sign in to comment.