diff options
Diffstat (limited to 'util/src/services/ChannelService.ts')
-rw-r--r-- | util/src/services/ChannelService.ts | 15 |
1 files changed, 6 insertions, 9 deletions
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,15 +84,18 @@ 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 }); } @@ -100,12 +103,6 @@ export class ChannelService { 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, user: await User.findOneOrFail({ where: { id: user_id }, select: PublicUserProjection }) |