diff --git a/src/api/routes/channels/#channel_id/tags.ts b/src/api/routes/channels/#channel_id/tags.ts
index 34b491565..c600752dd 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 57bc81832..493c3398a 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 000000000..c43167511
--- /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 .
+*/
+
+import { ChannelModifySchema } from "./ChannelModifySchema";
+
+export type ChannelCreateSchema = Omit;
diff --git a/src/schemas/uncategorised/ChannelModifySchema.ts b/src/schemas/uncategorised/ChannelModifySchema.ts
index 77836ca01..7230eed11 100644
--- a/src/schemas/uncategorised/ChannelModifySchema.ts
+++ b/src/schemas/uncategorised/ChannelModifySchema.ts
@@ -16,7 +16,7 @@
along with this program. If not, see .
*/
-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 3ea04519e..1f71bce38 100644
--- a/src/schemas/uncategorised/GuildCreateSchema.ts
+++ b/src/schemas/uncategorised/GuildCreateSchema.ts
@@ -16,7 +16,7 @@
along with this program. If not, see .
*/
-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 70c5cc30e..292e9c307 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 a18105453..f509bdd47 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";