From 296375c67e388e08b09a9bda16348103df48b75c Mon Sep 17 00:00:00 2001 From: AlTech98 Date: Sat, 18 Sep 2021 10:44:25 +0200 Subject: Fix gateway not listening for new channels events --- util/src/services/ChannelService.ts | 15 ++++++--------- util/src/util/Event.ts | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'util/src') diff --git a/util/src/services/ChannelService.ts b/util/src/services/ChannelService.ts index 8f57a28a..aa021a4a 100644 --- a/util/src/services/ChannelService.ts +++ b/util/src/services/ChannelService.ts @@ -84,27 +84,24 @@ export class ChannelService { return } - let channel_dto = null; + await emitEvent({ + event: "CHANNEL_DELETE", + data: await DmChannelDTO.from(channel, [user_id]), + user_id: user_id + }); //If the owner leave we make the first recipient in the list the new owner if (channel.owner_id === user_id) { channel.owner_id = channel.recipients!.find(r => r.user_id !== user_id)!.user_id //Is there a criteria to choose the new owner? - channel_dto = await DmChannelDTO.from(channel, [user_id]) await emitEvent({ event: "CHANNEL_UPDATE", - data: channel_dto, + data: await DmChannelDTO.from(channel, [user_id]), channel_id: channel.id }); } await channel.save() - await emitEvent({ - event: "CHANNEL_DELETE", - data: channel_dto !== null ? channel_dto : await DmChannelDTO.from(channel, [user_id]), - user_id: user_id - }); - await emitEvent({ event: "CHANNEL_RECIPIENT_REMOVE", data: { channel_id: channel.id, diff --git a/util/src/util/Event.ts b/util/src/util/Event.ts index ae296df9..765e5fc7 100644 --- a/util/src/util/Event.ts +++ b/util/src/util/Event.ts @@ -5,7 +5,6 @@ import { EVENT, Event } from "../interfaces"; const events = new EventEmitter(); export async function emitEvent(payload: Omit) { - console.log(payload) //TODO remove before merge const id = (payload.channel_id || payload.user_id || payload.guild_id) as string; if (!id) return console.error("event doesn't contain any id", payload); -- cgit 1.4.1