Skip to content

Commit f59cae7

Browse files
Merge pull request #1729 from ricaelchiquetti/main
improv: Ajustado isEmoji para aceitar todos os emojis.
2 parents 0e358cf + 85798b2 commit f59cae7

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

package-lock.json

Lines changed: 17 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"cors": "^2.8.5",
6767
"dayjs": "^1.11.13",
6868
"dotenv": "^16.4.7",
69+
"emoji-regex": "^10.4.0",
6970
"eventemitter2": "^6.4.9",
7071
"express": "^4.21.2",
7172
"express-async-errors": "^3.1.1",

src/api/controllers/sendMessage.controller.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ import {
1717
import { WAMonitoringService } from '@api/services/monitor.service';
1818
import { BadRequestException } from '@exceptions';
1919
import { isBase64, isURL } from 'class-validator';
20+
import emojiRegex from 'emoji-regex';
21+
22+
const regex = emojiRegex();
2023

2124
function isEmoji(str: string) {
2225
if (str === '') return true;
2326

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+
const match = str.match(regex);
28+
return match?.length === 1 && match[0] === str;
2729
}
2830

2931
export class SendMessageController {

0 commit comments

Comments
 (0)