summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeafus <leafus@fursystems.org>2026-08-14 09:23:42 +0200
committerRory& <root@rory.gay>2026-08-14 11:17:11 +0200
commit9394585e9d30ecaaaf842ba017c623a268bd76bb (patch)
tree8ad13c3d9f00c6a26027602f105c82967d135406
parentfeat: restore comments (diff)
downloadserver-ts-9394585e9d30ecaaaf842ba017c623a268bd76bb.tar.xz
feat: address issues
-rwxr-xr-x.husky/pre-commit1
-rw-r--r--src/gateway/opcodes/Identify.ts41
2 files changed, 24 insertions, 18 deletions
diff --git a/.husky/pre-commit b/.husky/pre-commit

index bc8bed76..7b270e72 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit
@@ -1,6 +1,5 @@ #!/usr/bin/env sh #!nix-shell -i "bash" -p bash prefetch-npm-deps jq nodejs nix-output-monitor -. "$(dirname -- "$0")/_/husky.sh" # Check if nix is available if [ -n "$(find "flake.lock" -mtime +7 -print)" ]; then diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index d0aaa99c..fac59cc9 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts
@@ -53,6 +53,7 @@ import { getMostRelevantSession, Presence, PresenceUpdateEvent, + PrivateStatus, ReadyEventData, ReadyGuildDTO, ReadyUserGuildSettingsEntries, @@ -329,21 +330,24 @@ export async function onIdentify(this: WebSocket, data: Payload) { const { result: friendPresenceSessions, elapsed: friendPresenceSessionsQueryTime } = await timePromise(() => friendPresenceUserIds.length === 0 ? Promise.resolve([] as Session[]) - : getDatabase()!.getRepository(Session).find({ - where: { - user_id: In(friendPresenceUserIds), - is_admin_session: false, - status: Not(In(["offline", "invisible"])), - }, - relations: { user: true }, - select: { - user_id: true, - status: true, - activities: true, - client_status: true, - user: Object.fromEntries(PublicUserProjection.map((x) => [x, true])), - }, - }), + : getDatabase()! + .getRepository(Session) + .find({ + where: { + user_id: In(friendPresenceUserIds), + is_admin_session: false, + // "unknown" isn't part of PrivateStatus, but clients can send it on identify, so guard against it having been persisted + status: Not(In(["offline", "invisible", "unknown"] as PrivateStatus[])), + }, + relations: { user: true }, + select: { + user_id: true, + status: true, + activities: true, + client_status: true, + user: Object.fromEntries(PublicUserProjection.map((x) => [x, true])), + }, + }), ); const { result: friendPresences, elapsed: generateFriendPresencesTime } = timeFunction<Presence[]>(() => { @@ -730,7 +734,7 @@ export async function onIdentify(this: WebSocket, data: Payload) { version: 0, // TODO }, private_channels: channels, - presences: [], + presences: [], // TODO: Send actual data session_id: this.session_id, country_code: this.session?.last_seen_location_info?.country_code ?? user.settings!.locale, users: Array.from(users), @@ -897,16 +901,19 @@ export async function onIdentify(this: WebSocket, data: Payload) { return { id: availableGuild.id, voice_states: availableGuild.voice_states.map((state) => VoiceState.prototype.toPublicVoiceState.apply(state)), + // embedded_activities is the older name for the same field, kept for clients that still read it + embedded_activities: [], activity_instances: [], }; }); + // TODO: ready supplemental - merged_members and guild presences are still empty await Send(this, { op: OPCodes.DISPATCH, t: EVENTEnum.ReadySupplemental, s: this.sequence++, d: { - guilds: readySupplementalGuilds, // { voice_states: [], id: string, embedded_activities: [] } + guilds: readySupplementalGuilds, // { voice_states: [], id: string, embedded_activities: [], activity_instances: [] } merged_members: guilds.map(() => []), // these merged members seem to be all users currently in vc in your guilds merged_presences: { friends: friendPresences,