Skip to content

Commit 5720bdc

Browse files
committed
✨ Remove reaction from a message
1 parent ab2364b commit 5720bdc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/api/controllers/sendMessage.controller.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import { WAMonitoringService } from '@api/services/monitor.service';
1818
import { BadRequestException } from '@exceptions';
1919
import { isBase64, isURL } from 'class-validator';
2020

21+
function isEmoji(str: string) {
22+
if (str === '') return true;
23+
24+
const emojiRegex = /^[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F000}-\u{1F02F}\u{1F0A0}-\u{1F0FF}\u{1F100}-\u{1F64F}\u{1F680}-\u{1F6FF}]$/u;
25+
return emojiRegex.test(str);
26+
}
27+
2128
export class SendMessageController {
2229
constructor(private readonly waMonitor: WAMonitoringService) {}
2330

@@ -81,8 +88,8 @@ export class SendMessageController {
8188
}
8289

8390
public async sendReaction({ instanceName }: InstanceDto, data: SendReactionDto) {
84-
if (!data.reaction.match(/[^()\w\sà-ú"-+]+/)) {
85-
throw new BadRequestException('"reaction" must be an emoji');
91+
if (!isEmoji(data.reaction)) {
92+
throw new BadRequestException('Reaction must be a single emoji or empty string');
8693
}
8794
return await this.waMonitor.waInstances[instanceName].reactionMessage(data);
8895
}

0 commit comments

Comments
 (0)