diff --git "a/src/api/routes/channels/\043channel_id/tags.ts" "b/src/api/routes/channels/\043channel_id/tags.ts"
index 34b4915..c600752 100644
--- "a/src/api/routes/channels/\043channel_id/tags.ts"
+++ "b/src/api/routes/channels/\043channel_id/tags.ts"
@@ -46,7 +46,10 @@
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/\043guild_id/channels.ts" "b/src/api/routes/guilds/\043guild_id/channels.ts"
index 57bc818..493c339 100644
--- "a/src/api/routes/guilds/\043guild_id/channels.ts"
+++ "b/src/api/routes/guilds/\043guild_id/channels.ts"
@@ -20,6 +20,7 @@
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.post(
"/",
route({
- requestBody: "ChannelModifySchema",
+ requestBody: "ChannelCreateSchema",
permission: "MANAGE_CHANNELS",
responses: {
201: {
@@ -64,7 +65,7 @@
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 0000000..c431675
--- /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 77836ca..7230eed 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 @@
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 3ea0451..1f71bce 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 @@
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 70c5cc3..292e9c3 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 a181054..f509bdd 100644
--- a/src/schemas/uncategorised/index.ts
+++ b/src/schemas/uncategorised/index.ts
@@ -96,3 +96,4 @@
export * from "./MessageActivity";
export * from "./PostDataSchema";
export * from "./TagCreateSchema";
+export * from "./ChannelCreateSchema";