Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct embed schemas #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions backend/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export const tEmbed = t.type({
video: tNullable(
t.type({
url: tNullable(t.string),
proxy_url: tNullable(t.string),
width: tNullable(t.number),
height: tNullable(t.number),
}),
Expand All @@ -298,8 +299,8 @@ export const tEmbed = t.type({
t.type({
name: t.string,
url: tNullable(t.string),
width: tNullable(t.number),
height: tNullable(t.number),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the fact that we should not allow setting these, as they are ignored by Discord's API, we cannot remove them from the schema as that would break existing configurations that are defining these properties. This also applies to the schema below

For clarity, I'm only talking about the removal of width and height.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, setting proxy URLs should also not be supported as that will also be ignored by Discord.

icon_url: tNullable(t.string),
proxy_icon_url: tNullable(t.string),
}),
),
});
Expand All @@ -315,12 +316,14 @@ export const zEmbedInput = z.object({
z.object({
text: z.string(),
icon_url: z.string().optional(),
proxy_icon_url: z.string().optional(),
}),
),

image: z.optional(
z.object({
url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(),
height: z.number().optional(),
}),
Expand All @@ -329,6 +332,7 @@ export const zEmbedInput = z.object({
thumbnail: z.optional(
z.object({
url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(),
height: z.number().optional(),
}),
Expand All @@ -337,6 +341,7 @@ export const zEmbedInput = z.object({
video: z.optional(
z.object({
url: z.string().optional(),
proxy_url: z.string().optional(),
width: z.number().optional(),
height: z.number().optional(),
}),
Expand Down Expand Up @@ -364,8 +369,8 @@ export const zEmbedInput = z.object({
z.object({
name: z.string(),
url: z.string().optional(),
width: z.number().optional(),
height: z.number().optional(),
icon_url: z.string().optional(),
proxy_icon_url: z.string().optional(),
}),
)
.nullable(),
Expand Down