mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-25 03:45:33 +00:00
so many type screw ups
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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">;
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -96,3 +96,4 @@ export * from "./ThreadCreationSchema";
|
||||
export * from "./MessageActivity";
|
||||
export * from "./PostDataSchema";
|
||||
export * from "./TagCreateSchema";
|
||||
export * from "./ChannelCreateSchema";
|
||||
|
||||
Reference in New Issue
Block a user