summary refs log tree commit diff
path: root/src/api/routes/guilds
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/routes/guilds')
-rw-r--r--src/api/routes/guilds/#guild_id/channels.ts55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/api/routes/guilds/#guild_id/channels.ts b/src/api/routes/guilds/#guild_id/channels.ts

index 68208fee..2676cb12 100644 --- a/src/api/routes/guilds/#guild_id/channels.ts +++ b/src/api/routes/guilds/#guild_id/channels.ts
@@ -21,9 +21,7 @@ import { Channel, ChannelModifySchema, ChannelReorderSchema, - ChannelUpdateEvent, Guild, - emitEvent, } from "@spacebar/util"; import { Request, Response, Router } from "express"; const router = Router(); @@ -106,59 +104,6 @@ router.patch( (x) => !body.find((c) => c.id == x), ); - const withParents = body.filter((x) => x.parent_id != undefined); - const withPositions = body.filter((x) => x.position != undefined); - - await Promise.all( - withPositions.map(async (opt) => { - const channel = await Channel.findOneOrFail({ - where: { id: opt.id }, - }); - - channel.position = opt.position as number; - notMentioned.splice(opt.position as number, 0, channel.id); - - await emitEvent({ - event: "CHANNEL_UPDATE", - data: channel, - channel_id: channel.id, - guild_id, - } as ChannelUpdateEvent); - }), - ); - - // have to do the parents after the positions - await Promise.all( - withParents.map(async (opt) => { - const [channel, parent] = await Promise.all([ - Channel.findOneOrFail({ - where: { id: opt.id }, - }), - Channel.findOneOrFail({ - where: { id: opt.parent_id as string }, - select: { permission_overwrites: true }, - }), - ]); - - if (opt.lock_permissions) - await Channel.update( - { id: channel.id }, - { permission_overwrites: parent.permission_overwrites }, - ); - - const parentPos = notMentioned.indexOf(parent.id); - notMentioned.splice(parentPos + 1, 0, channel.id); - channel.position = (parentPos + 1) as number; - - await emitEvent({ - event: "CHANNEL_UPDATE", - data: channel, - channel_id: channel.id, - guild_id, - } as ChannelUpdateEvent); - }), - ); - await Guild.update( { id: guild_id }, { channel_ordering: notMentioned },