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/server/services/messages/hooks/BeforeSaveCheckMAC.ts

24 lines
607 B

import { MeteorError, Omnichannel } from '@rocket.chat/core-services';
import { isOmnichannelRoom } from '@rocket.chat/core-typings';
import type { IRoom, IMessage } from '@rocket.chat/core-typings';
export class BeforeSaveCheckMAC {
async isWithinLimits({ message, room }: { message: IMessage; room: IRoom }): Promise<void> {
if (!isOmnichannelRoom(room)) {
return;
}
if (message.token) {
return;
}
if (message.t) {
return;
}
const canSendMessage = await Omnichannel.isWithinMACLimit(room);
if (!canSendMessage) {
throw new MeteorError('error-mac-limit-reached');
}
}
}