Allow poll answers and quick reactions on read only room

This commit is contained in:
N-Pex 2024-02-13 12:13:34 +01:00
parent 60d536062b
commit cd2640a85a
4 changed files with 26 additions and 7 deletions

View file

@ -41,7 +41,9 @@
v-on:download="download(selectedEvent)" v-on:more="
isEmojiQuickReaction= true
showMoreMessageOperations({event: selectedEvent, anchor: $event.anchor})
" :originalEvent="selectedEvent" :timelineSet="timelineSet" />
" :originalEvent="selectedEvent" :timelineSet="timelineSet"
:readOnlyRoom="$matrix.currentRoomIsReadOnlyForUser"
/>
</div>
<div ref="avatarOperationsStrut" class="avatar-operations-strut">

View file

@ -477,14 +477,25 @@ export default {
// Set power level event. Need to do that here, because we might not have the userId when the options object is created.
const powerLevels = {};
powerLevels[this.$matrix.currentUserId] = 100;
let powerLevelContent = {
users: powerLevels,
events_default: this.readOnlyRoom ? 50 : 0
}
if (this.readOnlyRoom) {
powerLevelContent.events = {
"m.room.encrypted": 0, // NOTE! Since practically all events in encrypted rooms get sent as "m.room.encrypted" we need to set
// power to 0 here. Otherwise we would not be able to send quick reactions or poll responses...
"m.poll.response": 0,
"org.matrix.msc3381.poll.response": 0,
"m.reaction": 0,
"m.room.redaction": 0,
};
}
createRoomOptions.initial_state.push(
{
type: "m.room.power_levels",
state_key: "",
content: {
users: powerLevels,
events_default: this.readOnlyRoom ? 50 : 0
}
content: powerLevelContent
});
return this.$matrix.matrixClient

View file

@ -15,7 +15,7 @@
</v-avatar>
<!-- SLOT FOR CONTENT -->
<slot></slot>
<div class="op-button" ref="opbutton" v-if="!event.isRedacted() && !$matrix.currentRoomIsReadOnlyForUser">
<div class="op-button" ref="opbutton" v-if="!event.isRedacted()">
<v-btn id="btn-more" icon @click.stop="showContextMenu($refs.opbutton)">
<v-icon>more_vert</v-icon>
</v-btn>

View file

@ -8,7 +8,7 @@
<v-btn id="btn-more" icon @click.stop="more" class="ma-0 pa-0">
<v-icon small> $vuetify.icons.addReaction </v-icon>
</v-btn>
<v-btn v-if="incoming" id="btn-reply" icon @click.stop="addReply" class="ma-0 pa-0">
<v-btn v-if="incoming && !readOnlyRoom" id="btn-reply" icon @click.stop="addReply" class="ma-0 pa-0">
<v-icon>reply</v-icon>
</v-btn>
<v-btn id="btn-edit" icon @click.stop="edit" class="ma-0 pa-0" v-if="isEditable">
@ -40,6 +40,12 @@ export default {
default: function () {
return []
}
},
readOnlyRoom: {
type: Boolean,
default: function () {
return false;
}
}
},
computed: {