summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-18 10:46:17 +0200
committerTomatoCake <60300461+DEVTomatoCake@users.noreply.github.com>2024-08-18 10:46:17 +0200
commitb7f966c8c2f88c02845417c0d54a681fcfda77d0 (patch)
tree4d3431951bed9700fab5b28fd19fb234093d21b0 /src
parentwidget.json channel_ordering, fix channel deletion (diff)
downloadserver-ts-b7f966c8c2f88c02845417c0d54a681fcfda77d0.tar.xz
Prettier, remove manual deletion of msgs
Diffstat (limited to 'src')
-rw-r--r--src/api/routes/guilds/#guild_id/widget.json.ts2
-rw-r--r--src/util/entities/Channel.ts21
2 files changed, 13 insertions, 10 deletions
diff --git a/src/api/routes/guilds/#guild_id/widget.json.ts b/src/api/routes/guilds/#guild_id/widget.json.ts

index 362a4a1c3..12b31b888 100644 --- a/src/api/routes/guilds/#guild_id/widget.json.ts +++ b/src/api/routes/guilds/#guild_id/widget.json.ts
@@ -51,7 +51,7 @@ router.get( where: { id: guild_id }, select: { channel_ordering: true, - } + }, }); if (!guild.widget_enabled) throw new HTTPError("Widget Disabled", 404); diff --git a/src/util/entities/Channel.ts b/src/util/entities/Channel.ts
index 9f19cb0d7..6538b5238 100644 --- a/src/util/entities/Channel.ts +++ b/src/util/entities/Channel.ts
@@ -459,8 +459,6 @@ export class Channel extends BaseClass { } static async deleteChannel(channel: Channel) { - await Message.delete({ channel_id: channel.id }); //TODO we should also delete the attachments from the cdn but to do that we need to move cdn.ts in util - //TODO before deleting the channel we should check and delete other relations await Channel.delete({ id: channel.id }); const guild = await Guild.findOneOrFail({ @@ -471,7 +469,10 @@ export class Channel extends BaseClass { const updatedOrdering = guild.channel_ordering.filter( (id) => id != channel.id, ); - await Guild.update({id: channel.guild_id}, { channel_ordering: updatedOrdering }); + await Guild.update( + { id: channel.guild_id }, + { channel_ordering: updatedOrdering }, + ); } static async calculatePosition( @@ -501,13 +502,15 @@ export class Channel extends BaseClass { ), ); - return channels.filter(channel => channel !== null).reduce((r, v) => { - v = v as Channel; + return channels + .filter((channel) => channel !== null) + .reduce((r, v) => { + v = v as Channel; - v.position = (guild as Guild).channel_ordering.indexOf(v.id); - r[v.position] = v; - return r; - }, [] as Array<Channel>); + v.position = (guild as Guild).channel_ordering.indexOf(v.id); + r[v.position] = v; + return r; + }, [] as Array<Channel>); } isDm() {