Skip to content

Commit ed762b9

Browse files
nickvergessenAntreesy
authored andcommitted
fix(chat): Allow to edit messages of bots in one-to-one conversations
Signed-off-by: Joas Schilling <[email protected]>
1 parent 340a635 commit ed762b9

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

lib/Controller/ChatController.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,11 @@ public function editMessage(int $messageId, string $message): DataResponse {
850850

851851
// Special case for if the message is a bridged message, then the message is the bridge bot's message.
852852
$isOwnMessage = $isOwnMessage || ($comment->getActorType() === Attendee::ACTOR_BRIDGED && $attendee->getActorId() === MatterbridgeManager::BRIDGE_BOT_USERID);
853-
if (!$isOwnMessage
853+
$isBotInOneToOne = $comment->getActorType() === Attendee::ACTOR_BOTS
854+
&& str_starts_with($comment->getActorId(), Attendee::ACTOR_BOT_PREFIX)
855+
&& ($this->room->getType() === Room::TYPE_ONE_TO_ONE
856+
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER);
857+
if (!($isOwnMessage || $isBotInOneToOne)
854858
&& (!$this->participant->hasModeratorPermissions(false)
855859
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE
856860
|| $this->room->getType() === Room::TYPE_ONE_TO_ONE_FORMER)) {

src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue

+7-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ export default {
523523

524524
isEditable() {
525525
if (!canEditMessage || !this.isModifiable || this.isObjectShare
526-
|| ((!this.$store.getters.isModerator || this.isOneToOne) && !this.isMyMsg)) {
526+
|| ((!this.$store.getters.isModerator || this.isOneToOne) && !(this.isMyMsg || this.isBotInOneToOne))) {
527527
return false
528528
}
529529

@@ -584,6 +584,12 @@ export default {
584584
&& this.actorType === this.$store.getters.getActorType()
585585
},
586586

587+
isBotInOneToOne() {
588+
return this.actorId.startsWith(ATTENDEE.BOT_PREFIX)
589+
&& this.actorType === ATTENDEE.ACTOR_TYPE.BOTS
590+
&& this.isOneToOne
591+
},
592+
587593
isConversationReadOnly() {
588594
return this.conversation.readOnly === CONVERSATION.STATE.READ_ONLY
589595
},

src/components/MessagesList/MessagesGroup/Message/MessagePart/MessageBody.vue

+8-2
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ import Quote from '../../../../Quote.vue'
147147
import CallButton from '../../../../TopBar/CallButton.vue'
148148

149149
import { useIsInCall } from '../../../../../composables/useIsInCall.js'
150-
import { CONVERSATION, PARTICIPANT } from '../../../../../constants.js'
150+
import { ATTENDEE, CONVERSATION, PARTICIPANT } from '../../../../../constants.js'
151151
import { EventBus } from '../../../../../services/EventBus.js'
152152
import { parseSpecialSymbols, parseMentions } from '../../../../../utils/textParse.ts'
153153

@@ -329,14 +329,20 @@ export default {
329329
&& this.actorType === this.$store.getters.getActorType()
330330
},
331331

332+
isBotInOneToOne() {
333+
return this.actorId.startsWith(ATTENDEE.BOT_PREFIX)
334+
&& this.actorType === ATTENDEE.ACTOR_TYPE.BOTS
335+
&& this.isOneToOne
336+
},
337+
332338
isOneToOne() {
333339
return this.conversation.type === CONVERSATION.TYPE.ONE_TO_ONE
334340
|| this.conversation.type === CONVERSATION.TYPE.ONE_TO_ONE_FORMER
335341
},
336342

337343
isEditable() {
338344
if (!canEditMessage || !this.isModifiable || this.isObjectShare
339-
|| ((!this.$store.getters.isModerator || this.isOneToOne) && !this.isMyMsg)) {
345+
|| ((!this.$store.getters.isModerator || this.isOneToOne) && !(this.isMyMsg || this.isBotInOneToOne))) {
340346
return false
341347
}
342348

src/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ export const ATTENDEE = {
124124
REMOTES: 'remotes',
125125
},
126126

127+
BOT_PREFIX: 'bot-',
127128
BRIDGE_BOT_ID: 'bridge-bot',
128129

129130
CHANGELOG_BOT_ID: 'changelog',

0 commit comments

Comments
 (0)