Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/mean-mails-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes Slack messages being incorrectly saved on import
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { IImportMessageRecord, IMessage as IDBMessage, IImportMessage, IImportMessageReaction } from '@rocket.chat/core-typings';
import { Rooms } from '@rocket.chat/models';
import { removeEmpty } from '@rocket.chat/tools';
import limax from 'limax';

import type { UserIdentification, MentionedChannel } from './ConverterCache';
Expand Down Expand Up @@ -84,7 +85,7 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
const mentions = data.mentions && (await this.convertMessageMentions(data));
const channels = data.channels && (await this.convertMessageChannels(data));

return {
return removeEmpty({
rid,
u: {
_id: creator._id,
Expand All @@ -110,7 +111,7 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
alias: data.alias,
...(data._id ? { _id: data._id } : {}),
...(data.reactions ? { reactions: await this.convertMessageReactions(data.reactions) } : {}),
};
});
}

protected async convertMessageChannels(message: IImportMessage): Promise<MentionedChannel[] | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ describe('Message Converter', () => {
});
});

it('should not have properties with undefined values', async () => {
const converter = new MessageConverter({ workInMemory: true });

const converted = await converter.buildMessageObject(messageToImport, 'general', { _id: 'rocket.cat', username: 'rocket.cat' });

Object.entries(converted).forEach(([key, value]) => {
expect(value, `Property "${key}" should not be undefined`).to.not.be.undefined;
});
});

// #TODO: Validate all message attributes
});

Expand Down
Loading