mirror of
https://github.com/versia-pub/api.git
synced 2026-03-13 20:29:15 +01:00
feat(federation): ✨ Improve federation module
This commit is contained in:
parent
e0b6d57470
commit
407e57fe34
10 changed files with 382 additions and 116 deletions
|
|
@ -5,7 +5,7 @@
|
|||
* @see https://lysand.org/extensions/custom-emojis
|
||||
*/
|
||||
import { z } from "zod";
|
||||
import { ContentFormat } from "../content_format";
|
||||
import { ContentFormatSchema } from "../content_format";
|
||||
import { emojiRegex } from "../regex";
|
||||
|
||||
/**
|
||||
|
|
@ -44,7 +44,7 @@ export const CustomEmojiExtension = z.object({
|
|||
emojiRegex,
|
||||
"Emoji name must be alphanumeric, underscores, or dashes.",
|
||||
),
|
||||
url: ContentFormat,
|
||||
url: ContentFormatSchema,
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
* @see https://lysand.org/extensions/polls
|
||||
*/
|
||||
import { z } from "zod";
|
||||
import { Extension } from "../base";
|
||||
import { ContentFormat } from "../content_format";
|
||||
import { ExtensionSchema } from "../base";
|
||||
import { ContentFormatSchema } from "../content_format";
|
||||
|
||||
/**
|
||||
* @description Poll extension entity
|
||||
|
|
@ -43,9 +43,9 @@ import { ContentFormat } from "../content_format";
|
|||
* "expires_at": "2021-01-04T00:00:00.000Z"
|
||||
* }
|
||||
*/
|
||||
export const Poll = Extension.extend({
|
||||
export const PollSchema = ExtensionSchema.extend({
|
||||
extension_type: z.literal("org.lysand:polls/Poll"),
|
||||
options: z.array(ContentFormat),
|
||||
options: z.array(ContentFormatSchema),
|
||||
votes: z.array(z.number().int().nonnegative()),
|
||||
multiple_choice: z.boolean().optional(),
|
||||
expires_at: z.string(),
|
||||
|
|
@ -65,7 +65,7 @@ export const Poll = Extension.extend({
|
|||
* "option": 1
|
||||
* }
|
||||
*/
|
||||
export const Vote = Extension.extend({
|
||||
export const VoteSchema = ExtensionSchema.extend({
|
||||
extension_type: z.literal("org.lysand:polls/Vote"),
|
||||
poll: z.string().url(),
|
||||
option: z.number(),
|
||||
|
|
@ -85,7 +85,7 @@ export const Vote = Extension.extend({
|
|||
* "votes": [9, 5, 0]
|
||||
* }
|
||||
*/
|
||||
export const VoteResult = Extension.extend({
|
||||
export const VoteResultSchema = ExtensionSchema.extend({
|
||||
extension_type: z.literal("org.lysand:polls/VoteResult"),
|
||||
poll: z.string().url(),
|
||||
votes: z.array(z.number().int().nonnegative()),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* @see https://lysand.org/extensions/reactions
|
||||
*/
|
||||
import { z } from "zod";
|
||||
import { Extension } from "../base";
|
||||
import { ExtensionSchema } from "../base";
|
||||
|
||||
/**
|
||||
* @description Reaction extension entity
|
||||
|
|
@ -21,7 +21,7 @@ import { Extension } from "../base";
|
|||
* "content": "👍"
|
||||
* }
|
||||
*/
|
||||
export const Reaction = Extension.extend({
|
||||
export const ReactionSchema = ExtensionSchema.extend({
|
||||
extension_type: z.literal("org.lysand:reactions/Reaction"),
|
||||
object: z.string().url(),
|
||||
content: z.string(),
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
* @see https://lysand.org/extensions/vanity
|
||||
*/
|
||||
|
||||
import { type AnyZodObject, ZodObject, z } from "zod";
|
||||
import { ContentFormat } from "../content_format";
|
||||
import { z } from "zod";
|
||||
import { ContentFormatSchema } from "../content_format";
|
||||
|
||||
/**
|
||||
* @description Vanity extension entity
|
||||
|
|
@ -67,11 +67,11 @@ import { ContentFormat } from "../content_format";
|
|||
* }
|
||||
* }
|
||||
*/
|
||||
export const VanityExtension = z.object({
|
||||
avatar_overlay: ContentFormat.optional(),
|
||||
avatar_mask: ContentFormat.optional(),
|
||||
background: ContentFormat.optional(),
|
||||
audio: ContentFormat.optional(),
|
||||
export const VanityExtensionSchema = z.object({
|
||||
avatar_overlay: ContentFormatSchema.optional(),
|
||||
avatar_mask: ContentFormatSchema.optional(),
|
||||
background: ContentFormatSchema.optional(),
|
||||
audio: ContentFormatSchema.optional(),
|
||||
pronouns: z.record(
|
||||
z.string(),
|
||||
z.array(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue