mirror of https://gitlab.com/litecord/litecord.git
users: fix some cross-scope inconsistency when dispatching
Closes #19. - dispatcher: remove dispatch_many_filter, add dispatch_many_filter_list
This commit is contained in:
parent
e627d61fd0
commit
54120bce0c
|
|
@ -211,17 +211,15 @@ async def patch_me():
|
||||||
friend_ids = await app.user_storage.get_friend_ids(user_id)
|
friend_ids = await app.user_storage.get_friend_ids(user_id)
|
||||||
|
|
||||||
session_ids.extend(
|
session_ids.extend(
|
||||||
await app.dispatcher.dispatch_many_filter(
|
await app.dispatcher.dispatch_many_filter_list(
|
||||||
'guild', guild_ids,
|
'guild', guild_ids, session_ids,
|
||||||
lambda sess_id: sess_id not in session_ids,
|
|
||||||
'USER_UPDATE', public_user
|
'USER_UPDATE', public_user
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
session_ids.extend(
|
session_ids.extend(
|
||||||
await app.dispatcher.dispatch_many_filter(
|
await app.dispatcher.dispatch_many_filter_list(
|
||||||
'friend', friend_ids,
|
'friend', friend_ids, session_ids,
|
||||||
lambda sess_id: sess_id not in session_ids,
|
|
||||||
'USER_UPDATE', public_user
|
'USER_UPDATE', public_user
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -114,20 +114,24 @@ class EventDispatcher:
|
||||||
key = backend.KEY_TYPE(key)
|
key = backend.KEY_TYPE(key)
|
||||||
return await backend.dispatch_filter(key, func, *args)
|
return await backend.dispatch_filter(key, func, *args)
|
||||||
|
|
||||||
async def dispatch_many_filter(self, backend_str, keys: List[Any],
|
async def dispatch_many_filter_list(self, backend_str: str,
|
||||||
func, *args) -> List[str]:
|
keys: List[Any], sess_list: List[str],
|
||||||
"""Call the dispatch_filter method to many keys.
|
*args):
|
||||||
|
"""Make a "unique" dispatch given a list of session ids.
|
||||||
|
|
||||||
Not all backends will handle this function.
|
This only works for backends that have a dispatch_filter
|
||||||
|
handler and return session id lists in their dispatch
|
||||||
|
results.
|
||||||
"""
|
"""
|
||||||
res = []
|
|
||||||
|
|
||||||
for key in keys:
|
for key in keys:
|
||||||
res.extend(
|
sess_list.extend(
|
||||||
await self.dispatch_filter(backend_str, key, func, *args)
|
await self.dispatch_filter(
|
||||||
|
backend_str, key,
|
||||||
|
lambda sess_id: sess_id not in sess_list,
|
||||||
|
*args)
|
||||||
)
|
)
|
||||||
|
|
||||||
return res
|
return sess_list
|
||||||
|
|
||||||
async def reset(self, backend_str: str, key: Any):
|
async def reset(self, backend_str: str, key: Any):
|
||||||
"""Reset the bucket in the given backend."""
|
"""Reset the bucket in the given backend."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue