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/processSetReaction.ts

26 lines
694 B

import type { IMessage } from '@rocket.chat/core-typings';
import { emoji } from '../../../../app/emoji/client';
import { callWithErrorHandling } from '../../utils/callWithErrorHandling';
import type { ChatAPI } from '../ChatAPI';
export const processSetReaction = async (chat: ChatAPI, { msg }: Pick<IMessage, 'msg'>): Promise<boolean> => {
const match = msg.trim().match(/^\+(:.*?:)$/m);
if (!match) {
return false;
}
const [, reaction] = match;
if (!emoji.list[reaction]) {
return false;
}
const lastMessage = await chat.data.findLastMessage();
if (!lastMessage) {
return false;
}
await callWithErrorHandling('setReaction', reaction, lastMessage._id);
return true;
};