The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/lib/chats/flows/processMessageEditing.ts

34 lines
861 B

import type { IMessage } from '@rocket.chat/core-typings';
import { MessageTypes } from '@rocket.chat/message-types';
import { dispatchToastMessage } from '../../toast';
import type { ChatAPI } from '../ChatAPI';
export const processMessageEditing = async (
chat: ChatAPI,
message: Pick<IMessage, '_id' | 't'> & Partial<Omit<IMessage, '_id' | 't'>>,
previewUrls?: string[],
): Promise<boolean> => {
const mid = chat.currentEditingMessage.getMID();
if (!mid) {
return false;
}
if (MessageTypes.isSystemMessage(message)) {
return false;
}
if (!message.msg && !message.attachments?.length && !message.content) {
return false;
}
try {
await chat.data.updateMessage({ ...message, _id: mid }, previewUrls);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
chat.currentEditingMessage.stop();
return true;
};