2025-02-13 02:34:44 +01:00
|
|
|
import { emojiValidator } from "@/api.ts";
|
2025-02-11 18:22:39 +01:00
|
|
|
import { z } from "@hono/zod-openapi";
|
2025-02-15 02:47:29 +01:00
|
|
|
import { config } from "~/config.ts";
|
2025-03-22 02:34:03 +01:00
|
|
|
import { Id, zBoolean } from "./common.ts";
|
2025-02-11 18:22:39 +01:00
|
|
|
|
|
|
|
|
export const CustomEmoji = z
|
|
|
|
|
.object({
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
id: Id.openapi({
|
|
|
|
|
description: "ID of the custom emoji in the database.",
|
|
|
|
|
example: "af9ccd29-c689-477f-aa27-d7d95fd8fb05",
|
|
|
|
|
}),
|
2025-02-13 02:34:44 +01:00
|
|
|
shortcode: z
|
|
|
|
|
.string()
|
|
|
|
|
.trim()
|
|
|
|
|
.min(1)
|
2025-02-15 02:47:29 +01:00
|
|
|
.max(config.validation.emojis.max_shortcode_characters)
|
2025-02-13 02:34:44 +01:00
|
|
|
.regex(
|
|
|
|
|
emojiValidator,
|
|
|
|
|
"Shortcode must only contain letters (any case), numbers, dashes or underscores.",
|
|
|
|
|
)
|
|
|
|
|
.openapi({
|
|
|
|
|
description: "The name of the custom emoji.",
|
|
|
|
|
example: "blobaww",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#shortcode",
|
|
|
|
|
},
|
|
|
|
|
}),
|
2025-02-11 18:22:39 +01:00
|
|
|
url: z
|
|
|
|
|
.string()
|
|
|
|
|
.url()
|
|
|
|
|
.openapi({
|
|
|
|
|
description: "A link to the custom emoji.",
|
|
|
|
|
example:
|
|
|
|
|
"https://cdn.versia.social/emojis/images/000/011/739/original/blobaww.png",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#url",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
static_url: z
|
|
|
|
|
.string()
|
|
|
|
|
.url()
|
|
|
|
|
.openapi({
|
|
|
|
|
description: "A link to a static copy of the custom emoji.",
|
|
|
|
|
example:
|
|
|
|
|
"https://cdn.versia.social/emojis/images/000/011/739/static/blobaww.png",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#static_url",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
visible_in_picker: z.boolean().openapi({
|
|
|
|
|
description:
|
|
|
|
|
"Whether this Emoji should be visible in the picker or unlisted.",
|
|
|
|
|
example: true,
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#visible_in_picker",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
category: z
|
|
|
|
|
.string()
|
2025-02-13 02:34:44 +01:00
|
|
|
.trim()
|
|
|
|
|
.max(64)
|
2025-02-11 18:22:39 +01:00
|
|
|
.nullable()
|
|
|
|
|
.openapi({
|
|
|
|
|
description: "Used for sorting custom emoji in the picker.",
|
|
|
|
|
example: "Blobs",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#category",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
global: zBoolean.openapi({
|
|
|
|
|
description: "Whether this emoji is visible to all users.",
|
|
|
|
|
example: false,
|
|
|
|
|
}),
|
|
|
|
|
/* Versia Server API extension */
|
|
|
|
|
description: z
|
|
|
|
|
.string()
|
2025-02-15 02:47:29 +01:00
|
|
|
.max(config.validation.emojis.max_description_characters)
|
2025-02-11 18:22:39 +01:00
|
|
|
.nullable()
|
|
|
|
|
.openapi({
|
|
|
|
|
description:
|
|
|
|
|
"Emoji description for users using screen readers.",
|
|
|
|
|
example: "A cute blob.",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji/#description",
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
})
|
2025-03-24 15:25:40 +01:00
|
|
|
.openapi("CustomEmoji", {
|
2025-02-11 18:22:39 +01:00
|
|
|
description: "Represents a custom emoji.",
|
|
|
|
|
externalDocs: {
|
|
|
|
|
url: "https://docs.joinmastodon.org/entities/CustomEmoji",
|
|
|
|
|
},
|
|
|
|
|
});
|