Skip to content

feat: add presences on ready_supplemental#1680

Open
leafusfluffy wants to merge 2 commits into
spacebarchat:masterfrom
leafusfluffy:ready_supplemental-presences
Open

feat: add presences on ready_supplemental#1680
leafusfluffy wants to merge 2 commits into
spacebarchat:masterfrom
leafusfluffy:ready_supplemental-presences

Conversation

@leafusfluffy

Copy link
Copy Markdown

This adds user and guild presences in READY_SUPPLEMENTAL Gateway response.

Comment thread src/gateway/opcodes/Identify.ts
where: {
user_id: In(friendPresenceUserIds),
is_admin_session: false,
status: Not(In(["offline", "invisible"])),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"unknown" is one i usually put in there too for good measure

Comment on lines -691 to +733
presences: [], // TODO: Send actual data
presences: [],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another disappearing comment

Comment on lines +328 to +348
const friendPresenceUserIds = [...new Set(relationships.filter((relationship) => relationship.type === RelationshipType.friends).map((relationship) => relationship.to_id))];
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])),
},
}),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this spam a bunch of db queries if you have a lot of friends?

Comment on lines +897 to +901
return {
id: availableGuild.id,
voice_states: availableGuild.voice_states.map((state) => VoiceState.prototype.toPublicVoiceState.apply(state)),
activity_instances: [],
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is embedded_activities not required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants