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;
|