mirror of https://gitlab.com/litecord/litecord.git
add friends to READY_SUPPLEMENTAL
This commit is contained in:
parent
777e789d77
commit
04512db4df
|
|
@ -113,16 +113,36 @@ def _complete_users_list(user_id: str, base_ready, user_ready, wsp) -> dict:
|
||||||
"id": relationship["id"],
|
"id": relationship["id"],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return ready
|
|
||||||
|
return ready, users_to_send
|
||||||
|
|
||||||
|
|
||||||
def _compute_supplemental(base_ready, user_ready, wsp):
|
async def _compute_supplemental(app, base_ready, user_ready, users_to_send: dict):
|
||||||
supplemental = {
|
supplemental = {
|
||||||
"merged_presences": {"guilds": [], "friends": []},
|
"merged_presences": {"guilds": [], "friends": []},
|
||||||
"merged_members": [],
|
"merged_members": [],
|
||||||
"guilds": [],
|
"guilds": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for relationship in user_ready["relationships"]:
|
||||||
|
if relationship["type"] != RelationshipType.FRIEND.value:
|
||||||
|
continue
|
||||||
|
|
||||||
|
friend_user = users_to_send[relationship["user"]["id"]]
|
||||||
|
friend_presence = await app.presence.friend_presences([int(friend_user["id"])])[
|
||||||
|
0
|
||||||
|
]
|
||||||
|
|
||||||
|
supplemental["merged_presences"]["friends"].append(
|
||||||
|
{
|
||||||
|
"user_id": relationship["user"]["id"],
|
||||||
|
"status": friend_presence["status"],
|
||||||
|
"last_modified": 0,
|
||||||
|
"client_status": friend_presence["client_status"],
|
||||||
|
"activities": friend_presence["activities"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
for guild in base_ready["guilds"]:
|
for guild in base_ready["guilds"]:
|
||||||
if guild["unavailable"]:
|
if guild["unavailable"]:
|
||||||
continue
|
continue
|
||||||
|
|
@ -503,10 +523,14 @@ class GatewayWebsocket:
|
||||||
# base_ready and user_ready are normalized as v6. from here onwards
|
# base_ready and user_ready are normalized as v6. from here onwards
|
||||||
# full_ready_data and ready_supplemental are version specific.
|
# full_ready_data and ready_supplemental are version specific.
|
||||||
|
|
||||||
full_ready_data = _complete_users_list(
|
# pass users_to_send to ready_supplemental so that its easier to
|
||||||
|
# cross-reference things
|
||||||
|
full_ready_data, users_to_send = _complete_users_list(
|
||||||
user["id"], base_ready, user_ready, self.wsp
|
user["id"], base_ready, user_ready, self.wsp
|
||||||
)
|
)
|
||||||
ready_supplemental = _compute_supplemental(base_ready, user_ready, self.wsp)
|
ready_supplemental = await _compute_supplemental(
|
||||||
|
self.app, base_ready, user_ready, users_to_send
|
||||||
|
)
|
||||||
|
|
||||||
if not self.state.bot:
|
if not self.state.bot:
|
||||||
for guild in full_ready_data["guilds"]:
|
for guild in full_ready_data["guilds"]:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue