Skip to content

Commit 5192f49

Browse files
Merge pull request #1259 from julianoaj/develop
✨ Feat: Remover a reação de uma mensagem.
2 parents 8f632a6 + 48b5fd4 commit 5192f49

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/api/controllers/sendMessage.controller.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ 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 =
25+
/^[\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;
26+
return emojiRegex.test(str);
27+
}
28+
2129
export class SendMessageController {
2230
constructor(private readonly waMonitor: WAMonitoringService) {}
2331

@@ -81,8 +89,8 @@ export class SendMessageController {
8189
}
8290

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

0 commit comments

Comments
 (0)