summary refs log tree commit diff
diff options
context:
space:
mode:
authorMathMan05 <mathmanrm@gmail.com>2026-02-05 11:00:51 -0600
committerMathMan05 <mathmanrm@gmail.com>2026-02-05 11:00:51 -0600
commitd7e468f3360f591244a9c14ab272f0dcf9e0dfc8 (patch)
tree7e83f79abf8aa236fed27c40b16ee405f106b61a
parentcreate tags (diff)
downloadserver-ts-d7e468f3360f591244a9c14ab272f0dcf9e0dfc8.tar.xz
so many type screw ups
-rw-r--r--src/api/routes/channels/#channel_id/tags.ts5
-rw-r--r--src/api/routes/guilds/#guild_id/channels.ts5
-rw-r--r--src/schemas/uncategorised/ChannelCreateSchema.ts21
-rw-r--r--src/schemas/uncategorised/ChannelModifySchema.ts3
-rw-r--r--src/schemas/uncategorised/GuildCreateSchema.ts4
-rw-r--r--src/schemas/uncategorised/TagCreateSchema.ts6
-rw-r--r--src/schemas/uncategorised/index.ts1
7 files changed, 36 insertions, 9 deletions
diff --git a/src/api/routes/channels/#channel_id/tags.ts b/src/api/routes/channels/#channel_id/tags.ts

index 34b49156..c600752d 100644 --- a/src/api/routes/channels/#channel_id/tags.ts +++ b/src/api/routes/channels/#channel_id/tags.ts
@@ -46,7 +46,10 @@ router.post( const tag = Tag.create({ channel, - ...body, + name: body.name, + moderated: body.moderated || false, + emoji_id: body.emoji_id || undefined, + emoji_name: body.emoji_name || undefined, }); channel.available_tags?.push(tag); diff --git a/src/api/routes/guilds/#guild_id/channels.ts b/src/api/routes/guilds/#guild_id/channels.ts
index 57bc8183..493c3398 100644 --- a/src/api/routes/guilds/#guild_id/channels.ts +++ b/src/api/routes/guilds/#guild_id/channels.ts
@@ -20,6 +20,7 @@ import { route } from "@spacebar/api"; import { Channel, ChannelUpdateEvent, Guild, emitEvent } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { ChannelModifySchema, ChannelReorderSchema } from "@spacebar/schemas"; +import { ChannelCreateSchema } from "../../../../schemas/uncategorised/ChannelCreateSchema"; const router = Router({ mergeParams: true }); router.get( @@ -47,7 +48,7 @@ router.get( router.post( "/", route({ - requestBody: "ChannelModifySchema", + requestBody: "ChannelCreateSchema", permission: "MANAGE_CHANNELS", responses: { 201: { @@ -64,7 +65,7 @@ router.post( async (req: Request, res: Response) => { // creates a new guild channel https://discord.com/developers/docs/resources/guild#create-guild-channel const { guild_id } = req.params as { [key: string]: string }; - const body = req.body as ChannelModifySchema; + const body = req.body as ChannelCreateSchema; const channel = await Channel.createChannel({ ...body, guild_id }, req.user_id); channel.position = await Channel.calculatePosition(channel.id, guild_id, channel.guild); diff --git a/src/schemas/uncategorised/ChannelCreateSchema.ts b/src/schemas/uncategorised/ChannelCreateSchema.ts new file mode 100644
index 00000000..c4316751 --- /dev/null +++ b/src/schemas/uncategorised/ChannelCreateSchema.ts
@@ -0,0 +1,21 @@ +/* + Spacebar: A FOSS re-implementation and extension of the Discord.com backend. + Copyright (C) 2023 Spacebar and Spacebar Contributors + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ + +import { ChannelModifySchema } from "./ChannelModifySchema"; + +export type ChannelCreateSchema = Omit<ChannelModifySchema, "available_tags">; diff --git a/src/schemas/uncategorised/ChannelModifySchema.ts b/src/schemas/uncategorised/ChannelModifySchema.ts
index 77836ca0..7230eed1 100644 --- a/src/schemas/uncategorised/ChannelModifySchema.ts +++ b/src/schemas/uncategorised/ChannelModifySchema.ts
@@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { ChannelPermissionOverwriteType, ChannelType } from "@spacebar/schemas"; +import { ChannelPermissionOverwriteType, ChannelType, TagCreateSchema } from "@spacebar/schemas"; export interface ChannelModifySchema { /** @@ -49,4 +49,5 @@ export interface ChannelModifySchema { auto_archive_duration?: number; archived?: boolean; locked?: boolean; + available_tags?: TagCreateSchema & { id: string }; } diff --git a/src/schemas/uncategorised/GuildCreateSchema.ts b/src/schemas/uncategorised/GuildCreateSchema.ts
index 3ea04519..1f71bce3 100644 --- a/src/schemas/uncategorised/GuildCreateSchema.ts +++ b/src/schemas/uncategorised/GuildCreateSchema.ts
@@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { ChannelModifySchema } from "@spacebar/schemas"; +import { ChannelCreateSchema } from "@spacebar/schemas"; export interface GuildCreateSchema { /** @@ -25,7 +25,7 @@ export interface GuildCreateSchema { name?: string; region?: string; icon?: string | null; - channels?: ChannelModifySchema[]; + channels?: ChannelCreateSchema[]; system_channel_id?: string; rules_channel_id?: string; guild_template_code?: string; diff --git a/src/schemas/uncategorised/TagCreateSchema.ts b/src/schemas/uncategorised/TagCreateSchema.ts
index 70c5cc30..292e9c30 100644 --- a/src/schemas/uncategorised/TagCreateSchema.ts +++ b/src/schemas/uncategorised/TagCreateSchema.ts
@@ -18,7 +18,7 @@ export interface TagCreateSchema { name: string; - moderated?: boolean; - emoji_id?: string; - emoji_name?: string; + moderated?: boolean | null; + emoji_id?: string | null; + emoji_name?: string | null; } diff --git a/src/schemas/uncategorised/index.ts b/src/schemas/uncategorised/index.ts
index a1810545..f509bdd4 100644 --- a/src/schemas/uncategorised/index.ts +++ b/src/schemas/uncategorised/index.ts
@@ -96,3 +96,4 @@ export * from "./ThreadCreationSchema"; export * from "./MessageActivity"; export * from "./PostDataSchema"; export * from "./TagCreateSchema"; +export * from "./ChannelCreateSchema";