summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-08-20 13:41:57 +0200
committerRory& <root@rory.gay>2026-08-20 13:41:57 +0200
commit427ff658574b76d6992bf3de3643a803fcc0f6ff (patch)
tree213ee315bfde9ef89d6c1b0140b3a417973bfa58
parentClean up some imports (diff)
parentMerge branch 'spacebarchat:master' into fix_relationship_events (diff)
downloadserver-ts-dev/gwsep.tar.xz
Merge remote-tracking branch 'leafusfluffy/fix_relationship_events' into dev/gwsep dev/gwsep
Diffstat (limited to '')
-rw-r--r--src/api/routes/users/@me/relationships.ts4
-rw-r--r--src/gateway/listener/listener.ts35
2 files changed, 24 insertions, 15 deletions
diff --git a/src/api/routes/users/@me/relationships.ts b/src/api/routes/users/@me/relationships.ts

index 07aa59f4d..cfa364783 100644 --- a/src/api/routes/users/@me/relationships.ts +++ b/src/api/routes/users/@me/relationships.ts
@@ -236,9 +236,9 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ await relationship.save(); } else { relationship = await Relationship.create({ - to_id: id, + to: friend, type: RelationshipType.blocked, - from_id: req.user_id, + from: user, }).save(); } diff --git a/src/gateway/listener/listener.ts b/src/gateway/listener/listener.ts
index fca34b137..10ad31f47 100644 --- a/src/gateway/listener/listener.ts +++ b/src/gateway/listener/listener.ts
@@ -239,12 +239,14 @@ async function consume(this: WebSocket, opts: EventOpts) { break; case "RELATIONSHIP_REMOVE": case "CHANNEL_DELETE": - case "GUILD_DELETE": - this.events[id]?.(); - delete this.events[id]; + case "GUILD_DELETE": { + const removed_id = data.id as string; + if (!removed_id) break; + this.events[removed_id]?.(); + delete this.events[removed_id]; if (event === "GUILD_DELETE" && this.ipAddress) { const ban = await Ban.findOne({ - where: { guild_id: id, user_id: this.user_id }, + where: { guild_id: removed_id, user_id: this.user_id }, }); if (ban) { @@ -253,30 +255,37 @@ async function consume(this: WebSocket, opts: EventOpts) { } } break; - case "CHANNEL_CREATE": + } + case "CHANNEL_CREATE": { if (!permission.overwriteChannel(data.permission_overwrites).has("VIEW_CHANNEL")) return; - this.events[id] = await listenEvent(id, consumer, listenOpts); + const channel_id = data.id as string; + this.events[channel_id] = await listenEvent(channel_id, consumer, listenOpts); break; + } case "RELATIONSHIP_ADD": - this.events[data.user.id] = await listenEvent(data.user.id, handlePresenceUpdate.bind(this), this.listen_options); + // don't let a payload without a user object stop the dispatch below + if (data.user?.id) this.events[data.user.id] = await listenEvent(data.user.id, handlePresenceUpdate.bind(this), this.listen_options); break; - case "GUILD_CREATE": + case "GUILD_CREATE": { + const guild_id = data.id as string; await Promise.all([ ...data.channels.map(async ({ id }: { id: string }) => { this.events[id] = await listenEvent(id, consumer, listenOpts); }), - listenEvent(id, consumer, listenOpts).then((ret) => (this.events[id] = ret)), + listenEvent(guild_id, consumer, listenOpts).then((ret) => (this.events[guild_id] = ret)), ]); break; + } case "CHANNEL_UPDATE": { - const exists = this.events[id]; + const channel_id = data.id as string; + const exists = this.events[channel_id]; if (permission.overwriteChannel(data.permission_overwrites).has("VIEW_CHANNEL")) { if (exists) break; - this.events[id] = await listenEvent(id, consumer, listenOpts); + this.events[channel_id] = await listenEvent(channel_id, consumer, listenOpts); } else { if (!exists) return; // return -> do not send channel update events for hidden channels - opts.cancel(id); - delete this.events[id]; + opts.cancel(channel_id); + delete this.events[channel_id]; } break; }