File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ 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 = / ^ [ \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+
2128export 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 }
You can’t perform that action at this time.
0 commit comments