diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-13 00:17:56 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-13 00:17:56 +0200 |
commit | 13b7b847618b520112af568c5cd71a6068d576c0 (patch) | |
tree | a2261f8cca6ff7186d3c92897015ee2e9a391608 | |
parent | :bug: fix invites: ajv doesn't treat null as undefined (diff) | |
download | server-13b7b847618b520112af568c5cd71a6068d576c0.tar.xz |
:bug: fix channel events + message send
-rw-r--r-- | bundle/package.json | 3 | ||||
-rw-r--r-- | gateway/src/listener/listener.ts | 26 | ||||
-rw-r--r-- | util/src/entities/Channel.ts | 1 |
3 files changed, 17 insertions, 13 deletions
diff --git a/bundle/package.json b/bundle/package.json index 996ab30b..83f26116 100644 --- a/bundle/package.json +++ b/bundle/package.json @@ -11,7 +11,8 @@ "build:api": "cd ../api/ && npm run build", "build:cdn": "cd ../cdn/ && npm run build", "build:gateway": "cd ../gateway/ && npm run build", - "start": "npm run build && node -r ./tsconfig-paths-bootstrap.js dist/start.js", + "start": "npm run build && npm run start:bundle", + "start:bundle": "node -r ./tsconfig-paths-bootstrap.js dist/start.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/gateway/src/listener/listener.ts b/gateway/src/listener/listener.ts index e5630a43..7152c74b 100644 --- a/gateway/src/listener/listener.ts +++ b/gateway/src/listener/listener.ts @@ -26,16 +26,16 @@ import { Recipient } from "@fosscord/util"; // TODO: use already queried guilds/channels of Identify and don't fetch them again export async function setupListener(this: WebSocket) { - const members = await Member.find({ id: this.user_id }); - const guild_ids = members.map((x) => x.guild_id); - const user = await User.findOneOrFail({ id: this.user_id }); + const members = await Member.find({ + where: { id: this.user_id }, + relations: ["guild", "guild.channels"], + }); + const guilds = members.map((x) => x.guild); const recipients = await Recipient.find({ where: { user_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, @@ -54,18 +54,20 @@ export async function setupListener(this: WebSocket) { this.events[channel.id] = await listenEvent(channel.id, consumer, opts); } - for (const guild of guild_ids) { + for (const guild of guilds) { // contains guild and dm channels - getPermission(this.user_id, guild) + getPermission(this.user_id, guild.id) .then(async (x) => { - this.permissions[guild] = x; + this.permissions[guild.id] = x; this.listeners; - this.events[guild] = await listenEvent(guild, consumer, opts); + this.events[guild.id] = await listenEvent( + guild.id, + consumer, + opts + ); - for (const channel of guild_channels.filter( - (c) => c.guild_id === guild - )) { + for (const channel of guild.channels) { if ( x .overwriteChannel(channel.permission_overwrites) diff --git a/util/src/entities/Channel.ts b/util/src/entities/Channel.ts index fce85e3f..592b0b83 100644 --- a/util/src/entities/Channel.ts +++ b/util/src/entities/Channel.ts @@ -61,6 +61,7 @@ export class Channel extends BaseClass { @ManyToOne(() => Channel) parent?: Channel; + // only for group dms @Column({ nullable: true }) @RelationId((channel: Channel) => channel.owner) owner_id: string; |