2024-05-14 09:00:05 +02:00
|
|
|
/**
|
|
|
|
|
* Custom emojis extension.
|
|
|
|
|
* @module federation/schemas/extensions/custom_emojis
|
|
|
|
|
* @see module:federation/schemas/base
|
2024-08-24 14:58:50 +02:00
|
|
|
* @see https://versia.pub/extensions/custom-emojis
|
2024-05-14 09:00:05 +02:00
|
|
|
*/
|
|
|
|
|
import { z } from "zod";
|
2024-07-23 00:11:05 +02:00
|
|
|
import { ContentFormatSchema } from "../content_format";
|
|
|
|
|
import { emojiRegex } from "../regex";
|
2024-05-14 09:00:05 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @description Used to validate the properties the extension's custom field
|
2024-08-24 14:58:50 +02:00
|
|
|
* @see https://versia.pub/extensions/custom-emojis
|
2024-05-14 09:00:05 +02:00
|
|
|
* @example
|
|
|
|
|
* {
|
|
|
|
|
* // ...
|
|
|
|
|
* "extensions": {
|
|
|
|
|
* "org.lysand:custom_emojis": {
|
|
|
|
|
* "emojis": [
|
|
|
|
|
* {
|
|
|
|
|
* "name": "happy_face",
|
|
|
|
|
* "url": {
|
|
|
|
|
* "image/png": {
|
|
|
|
|
* "content": "https://cdn.example.com/emojis/happy_face.png",
|
|
|
|
|
* "content_type": "image/png"
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
* },
|
|
|
|
|
* // ...
|
|
|
|
|
* ]
|
|
|
|
|
* }
|
|
|
|
|
* }
|
|
|
|
|
* // ...
|
|
|
|
|
* }
|
|
|
|
|
*/
|
2024-06-20 00:21:34 +02:00
|
|
|
export const CustomEmojiExtensionSchema = z.object({
|
2024-05-14 09:00:05 +02:00
|
|
|
emojis: z.array(
|
|
|
|
|
z.object({
|
|
|
|
|
name: z
|
|
|
|
|
.string()
|
|
|
|
|
.min(1)
|
|
|
|
|
.max(256)
|
|
|
|
|
.regex(
|
|
|
|
|
emojiRegex,
|
|
|
|
|
"Emoji name must be alphanumeric, underscores, or dashes.",
|
|
|
|
|
),
|
2024-05-14 21:08:46 +02:00
|
|
|
url: ContentFormatSchema,
|
2024-05-14 09:00:05 +02:00
|
|
|
}),
|
|
|
|
|
),
|
|
|
|
|
});
|