summary refs log tree commit diff
path: root/gateway/src/listener
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-31 17:58:28 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-31 17:58:28 +0200
commitadc75ca76b5561d6d4e8d01c5fdd574f8b98363a (patch)
tree81840d8752cb76b8737bb7749af8c04b33ca44a3 /gateway/src/listener
parentChannel utility methods in entity (diff)
downloadserver-adc75ca76b5561d6d4e8d01c5fdd574f8b98363a.tar.xz
:sparkles: channel recipients
Diffstat (limited to 'gateway/src/listener')
-rw-r--r--gateway/src/listener/listener.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/gateway/src/listener/listener.ts b/gateway/src/listener/listener.ts

index 8fa96555..75ca1680 100644 --- a/gateway/src/listener/listener.ts +++ b/gateway/src/listener/listener.ts
@@ -14,7 +14,8 @@ import { Send } from "../util/Send"; import WebSocket from "../util/WebSocket"; import "missing-native-js-functions"; import { Channel as AMQChannel } from "amqplib"; -import { In } from "../../../util/node_modules/typeorm"; +import { In, Like } from "../../../util/node_modules/typeorm"; +import { Recipient } from "../../../util/dist/entities/Recipient"; // TODO: close connection on Invalidated Token // TODO: check intent @@ -28,10 +29,9 @@ export async function setupListener(this: WebSocket) { const members = await Member.find({ where: { id: this.user_id } }); const guild_ids = members.map((x) => x.guild_id); const user = await User.findOneOrFail({ id: this.user_id }); - const channels = await Channel.find({ - where: [{ recipient_ids: this.user_id }, { guild_id: In(guild_ids) }], - }); - const dm_channels = channels.filter((x) => !x.guild_id); + const recipients = await Recipient.find({ where: { id: this.user_id }, relations: ["channel"] }); + const channels = await Channel.find({ guild_id: In(guild_ids) }); + const dm_channels = recipients.map((x) => x.channel); const guild_channels = channels.filter((x) => x.guild_id); const opts: { acknowledge: boolean; channel?: AMQChannel } = { acknowledge: true };