mirror of https://gitlab.com/litecord/litecord.git
pubsub.lazy_guild: fix bugs around p_idx calculation
This commit is contained in:
parent
3b532fa8b0
commit
748eacf112
|
|
@ -482,6 +482,7 @@ class GuildMemberList:
|
||||||
await self._dispatch_sess([session_id], ops)
|
await self._dispatch_sess([session_id], ops)
|
||||||
|
|
||||||
def get_item_index(self, user_id: Union[str, int]):
|
def get_item_index(self, user_id: Union[str, int]):
|
||||||
|
"""Get the item index a user is on."""
|
||||||
def _get_id(item):
|
def _get_id(item):
|
||||||
# item can be a group item or a member item
|
# item can be a group item or a member item
|
||||||
return item.get('member', {}).get('user', {}).get('id')
|
return item.get('member', {}).get('user', {}).get('id')
|
||||||
|
|
@ -514,7 +515,7 @@ class GuildMemberList:
|
||||||
async def _pres_update_simple(self, user_id: int):
|
async def _pres_update_simple(self, user_id: int):
|
||||||
item_index = self.get_item_index(user_id)
|
item_index = self.get_item_index(user_id)
|
||||||
|
|
||||||
if not item_index:
|
if item_index is None:
|
||||||
log.warning('lazy guild got invalid pres update uid={}',
|
log.warning('lazy guild got invalid pres update uid={}',
|
||||||
user_id)
|
user_id)
|
||||||
return []
|
return []
|
||||||
|
|
@ -584,7 +585,9 @@ class GuildMemberList:
|
||||||
# dispatch events to both the old states and
|
# dispatch events to both the old states and
|
||||||
# new states.
|
# new states.
|
||||||
return await self._dispatch_sess(
|
return await self._dispatch_sess(
|
||||||
session_ids_old + session_ids_new,
|
# inefficient, but necessary since we
|
||||||
|
# want to merge both session ids.
|
||||||
|
list(session_ids_old) + list(session_ids_new),
|
||||||
[
|
[
|
||||||
Operation('DELETE', {
|
Operation('DELETE', {
|
||||||
'index': old_item_index,
|
'index': old_item_index,
|
||||||
|
|
@ -628,7 +631,11 @@ class GuildMemberList:
|
||||||
lambda p: p['user']['id'] == str(user_id),
|
lambda p: p['user']['id'] == str(user_id),
|
||||||
presences)
|
presences)
|
||||||
|
|
||||||
if not p_idx:
|
log.debug('p_idx for group {!r} = {}',
|
||||||
|
group.gid, p_idx)
|
||||||
|
|
||||||
|
if p_idx is None:
|
||||||
|
log.debug('skipping group {}', group)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# make a copy since we're modifying in-place
|
# make a copy since we're modifying in-place
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue