diff --git a/src/composables/__tests__/useMessageInfo.spec.js b/src/composables/__tests__/useMessageInfo.spec.js index bd4fd0308ee..9549b55f588 100644 --- a/src/composables/__tests__/useMessageInfo.spec.js +++ b/src/composables/__tests__/useMessageInfo.spec.js @@ -99,7 +99,7 @@ describe('message actions', () => { mockConversationInfo = { isOneToOneConversation: computed(() => false), isConversationReadOnly: computed(() => true), - isConversationModifiable: computed(() => true), + isConversationModifiable: computed(() => false), } useConversationInfo.mockReturnValue(mockConversationInfo) // Act @@ -226,6 +226,15 @@ describe('message actions', () => { expect(result.isEditable.value).toBe(false) }) + test('system message is not editable', () => { + // Arrange + messageProps.systemMessage = 'system-message' + // Act + const result = useMessageInfo(messageProps.token, messageProps.id) + // Assert + expect(result.isEditable.value).toBe(false) + }) + test('message is not editable when the conversation is not modifiable', () => { // Arrange mockConversationInfo = { diff --git a/src/composables/useMessageInfo.js b/src/composables/useMessageInfo.js index 2bcc1d70782..c7508a59584 100644 --- a/src/composables/useMessageInfo.js +++ b/src/composables/useMessageInfo.js @@ -58,7 +58,7 @@ export function useMessageInfo(tokenRef = ref(null), messageIdRef = ref(null)) { ) const isEditable = computed(() => { - if (!canEditMessage || !isConversationModifiable.value || isObjectShare.value + if (!canEditMessage || !isConversationModifiable.value || isObjectShare.value || message.value.systemMessage || ((!store.getters.isModerator || isOneToOneConversation.value) && !isCurrentUserOwnMessage.value)) { return false } @@ -70,16 +70,11 @@ export function useMessageInfo(tokenRef = ref(null), messageIdRef = ref(null)) { const isFileShareWithoutCaption = computed(() => message.value.message === '{file}' && isFileShare.value) - const isDeleteable = computed(() => { - if (!isConversationModifiable.value) { - return false - } - - return (canDeleteMessageUnlimited || (moment(message.value.timestamp * 1000).add(6, 'h')) > moment()) - && (message.value.messageType === 'comment' || message.value.messageType === 'voice-message') - && (isCurrentUserOwnMessage.value || (!isOneToOneConversation.value && store.getters.isModerator)) - && !isConversationReadOnly.value - }) + const isDeleteable = computed(() => + (canDeleteMessageUnlimited || (moment(message.value.timestamp * 1000).add(6, 'h')) > moment()) + && (message.value.messageType === 'comment' || message.value.messageType === 'voice-message') + && (isCurrentUserOwnMessage.value || (!isOneToOneConversation.value && store.getters.isModerator)) + && isConversationModifiable.value) return { isEditable,