Skip to content

Commit

Permalink
Allow emojis (#1218)
Browse files Browse the repository at this point in the history
* allow emojis

* support

* add comments

* lint
  • Loading branch information
andy-t-wang authored Feb 26, 2025
1 parent bcf0acf commit d57c644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions web/api/v2/minikit/send-notification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { verifyHashedSecret } from "@/api/helpers/utils";
import { validateRequestSchema } from "@/api/helpers/validate-request-schema";
import { logger } from "@/lib/logger";
import {
allowedCommonCharactersRegex,
allowedTitleCharactersRegex,
allowTitleAndEmojisRegex,
allowCommonCharactersAndEmojisRegex,
} from "@/lib/schema";
import { createSignedFetcher } from "aws-sigv4-fetch";
import { GraphQLClient } from "graphql-request";
Expand All @@ -32,7 +32,7 @@ const sendNotificationBodySchema = yup.object({
.required()
.max(200)
.matches(
allowedCommonCharactersRegex,
allowCommonCharactersAndEmojisRegex,
"Message can only contain letters, numbers, punctuation, and spaces",
),
title: yup
Expand All @@ -41,7 +41,7 @@ const sendNotificationBodySchema = yup.object({
.optional()
.max(30)
.matches(
allowedTitleCharactersRegex,
allowTitleAndEmojisRegex,
"Title can only contain letters, numbers, punctuation, and spaces",
),
mini_app_path: yup.string().strict().required(),
Expand Down
8 changes: 8 additions & 0 deletions web/lib/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export const allowedCommonCharactersRegex =
export const allowedTitleCharactersRegex =
/^[\u3000-\u303F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\p{Letter}\p{Mark}\s0-9!,:/+&$._-]+$/u;

/** use for common characters and emojis */
export const allowCommonCharactersAndEmojisRegex =
/^[\u{1F000}-\u{1F9FF}\u3000-\u303F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\p{Letter}\p{Mark}\p{Punctuation}\s0-9+$]*[^{\\}]$/u;

/** use for titles with emojis */
export const allowTitleAndEmojisRegex =
/^[\u{1F000}-\u{1F9FF}/^[\u3000-\u303F\u4E00-\u9FFF\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\p{Letter}\p{Mark}\s0-9!,:/+&$._-]+$/u;

export const httpsLinkSchema = ({
excludeEmptyString = false,
}: {
Expand Down

0 comments on commit d57c644

Please sign in to comment.