1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-22 02:12:40 +01:00

Prettier, remove manual deletion of msgs

This commit is contained in:
TomatoCake 2024-08-18 10:46:17 +02:00
parent cae9d7ebed
commit b7f966c8c2
2 changed files with 13 additions and 10 deletions

View File

@ -51,7 +51,7 @@ router.get(
where: { id: guild_id },
select: {
channel_ordering: true,
}
},
});
if (!guild.widget_enabled) throw new HTTPError("Widget Disabled", 404);

View File

@ -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() {