summary refs log tree commit diff
path: root/api/src/routes/channels
diff options
context:
space:
mode:
authorAlTech98 <altech123159@gmail.com>2021-09-17 18:29:02 +0200
committerAlTech98 <altech123159@gmail.com>2021-09-17 18:29:02 +0200
commit6123f359b0b58e72da70d0f0d89cc7714d54f8b6 (patch)
treedb64b13077038f94a2d32979641229d25f7871f8 /api/src/routes/channels
parentMerge branch 'fosscord:master' into fix-dm (diff)
downloadserver-6123f359b0b58e72da70d0f0d89cc7714d54f8b6.tar.xz
Fix icon, owner_id change and channel deletion for group DMs
Diffstat (limited to 'api/src/routes/channels')
-rw-r--r--api/src/routes/channels/#channel_id/index.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/api/src/routes/channels/#channel_id/index.ts b/api/src/routes/channels/#channel_id/index.ts
index e836622b..70dd3994 100644
--- a/api/src/routes/channels/#channel_id/index.ts
+++ b/api/src/routes/channels/#channel_id/index.ts
@@ -1,6 +1,6 @@
 import { Channel, ChannelDeleteEvent, ChannelPermissionOverwriteType, ChannelService, ChannelType, ChannelUpdateEvent, emitEvent, Recipient } from "@fosscord/util";
 import { Request, Response, Router } from "express";
-import { route } from "@fosscord/api";
+import { handleFile, route } from "@fosscord/api";
 
 const router: Router = Router();
 // TODO: delete channel
@@ -44,9 +44,10 @@ export interface ChannelModifySchema {
 	/**
 	 * @maxLength 100
 	 */
-	name: string;
-	type: ChannelType;
+	name?: string;
+	type?: ChannelType;
 	topic?: string;
+	icon?: string | null;
 	bitrate?: number;
 	user_limit?: number;
 	rate_limit_per_user?: number;
@@ -67,6 +68,7 @@ export interface ChannelModifySchema {
 router.patch("/", route({ body: "ChannelModifySchema", permission: "MANAGE_CHANNELS" }), async (req: Request, res: Response) => {
 	var payload = req.body as ChannelModifySchema;
 	const { channel_id } = req.params;
+	if (payload.icon) payload.icon = await handleFile(`/channel-icons/${channel_id}`, payload.icon);
 
 	const channel = await Channel.findOneOrFail({ id: channel_id });
 	channel.assign(payload);