File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ import { WAMonitoringService } from '@api/services/monitor.service';
1818import { BadRequestException } from '@exceptions' ;
1919import { 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+
2129export 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 }
You can’t perform that action at this time.
0 commit comments