gateway: remove own user from ready.users

This commit is contained in:
Luna 2021-06-26 00:12:52 -03:00
parent a51c98de0f
commit 6df48316f5
1 changed files with 4 additions and 2 deletions

View File

@ -69,7 +69,7 @@ WebsocketProperties = collections.namedtuple(
) )
def _complete_users_list(base_ready, user_ready) -> dict: def _complete_users_list(user_id: str, base_ready, user_ready) -> dict:
"""Use the data we were already preparing to send in READY to construct """Use the data we were already preparing to send in READY to construct
the users array, saving on I/O cost.""" the users array, saving on I/O cost."""
@ -86,6 +86,8 @@ def _complete_users_list(base_ready, user_ready) -> dict:
for recipient in private_channel["recipients"]: for recipient in private_channel["recipients"]:
users_to_send[recipient["id"]] = recipient users_to_send[recipient["id"]] = recipient
users_to_send.pop(user_id)
ready = {**base_ready, **user_ready} ready = {**base_ready, **user_ready}
ready["users"] = [value for value in users_to_send.values()] ready["users"] = [value for value in users_to_send.values()]
return ready return ready
@ -400,7 +402,7 @@ class GatewayWebsocket:
"shard": [self.state.current_shard, self.state.shard_count], "shard": [self.state.current_shard, self.state.shard_count],
} }
full_ready_data = _complete_users_list(base_ready, user_ready) full_ready_data = _complete_users_list(user["id"], base_ready, user_ready)
await self.dispatch("READY", full_ready_data) await self.dispatch("READY", full_ready_data)
app.sched.spawn(self._guild_dispatch(guilds)) app.sched.spawn(self._guild_dispatch(guilds))