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
6 changes: 6 additions & 0 deletions .changeset/healthy-colts-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/core-typings': patch
'@rocket.chat/meteor': patch
---

Fixes editing of encrypted message attachment description.
8 changes: 5 additions & 3 deletions apps/meteor/client/lib/parseMessageTextToAstMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isQuoteAttachment,
isTranslatedAttachment,
isTranslatedMessage,
isEncryptedMessageAttachment,
} from '@rocket.chat/core-typings';
import type { Options, Root } from '@rocket.chat/message-parser';
import { parse } from '@rocket.chat/message-parser';
Expand Down Expand Up @@ -77,9 +78,10 @@ export const parseMessageAttachment = <T extends MessageAttachment>(
'';

if (isFileAttachment(attachment) && attachment.description) {
attachment.descriptionMd = translated
? textToMessageToken(text, parseOptions)
: (attachment.descriptionMd ?? textToMessageToken(text, parseOptions));
attachment.descriptionMd =
translated || isEncryptedMessageAttachment(attachment)
? textToMessageToken(text, parseOptions)
: (attachment.descriptionMd ?? textToMessageToken(text, parseOptions));
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test.describe('E2EE File Encryption', () => {
await page.goto('/home');
});

test('File and description encryption', async ({ page }) => {
test('File and description encryption and editing the description', async ({ page }) => {
await test.step('create an encrypted channel', async () => {
const channelName = faker.string.uuid();

Expand All @@ -59,6 +59,18 @@ test.describe('E2EE File Encryption', () => {
await expect(poHomeChannel.content.getFileDescription).toHaveText('any_description');
await expect(poHomeChannel.content.lastMessageFileName).toContainText('any_file1.txt');
});

await test.step('edit the description', async () => {
await poHomeChannel.content.openLastMessageMenu();
await poHomeChannel.content.btnOptionEditMessage.click();

expect(await poHomeChannel.composer.inputValue()).toBe('any_description');

await poHomeChannel.content.inputMessage.fill('edited any_description');
await page.keyboard.press('Enter');

await expect(poHomeChannel.content.getFileDescription).toHaveText('edited any_description');
});
});

test('File encryption with whitelisted and blacklisted media types', async ({ page, api }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ export type MessageAttachmentBase = {
sha256: string;
};
};

export type EncryptedMessageAttachment = MessageAttachmentBase & {
encryption: Required<MessageAttachmentBase>['encryption'];
};

export const isEncryptedMessageAttachment = (attachment: MessageAttachmentBase): attachment is EncryptedMessageAttachment => {
return attachment?.encryption !== undefined && typeof attachment.encryption === 'object';
};
Loading