Fix no dispatch on shared API token removal (#4917)

This commit is contained in:
jack1142 2021-04-05 22:28:23 +02:00 committed by GitHub
parent a6d15dc385
commit c574271cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1285,6 +1285,7 @@ class RedBase(
async with self._config.custom(SHARED_API_TOKENS, service_name).all() as group: async with self._config.custom(SHARED_API_TOKENS, service_name).all() as group:
for name in token_names: for name in token_names:
group.pop(name, None) group.pop(name, None)
self.dispatch("red_api_tokens_update", service_name, MappingProxyType(group))
async def remove_shared_api_services(self, *service_names: str): async def remove_shared_api_services(self, *service_names: str):
""" """
@ -1304,6 +1305,9 @@ class RedBase(
async with self._config.custom(SHARED_API_TOKENS).all() as group: async with self._config.custom(SHARED_API_TOKENS).all() as group:
for service in service_names: for service in service_names:
group.pop(service, None) group.pop(service, None)
# dispatch needs to happen *after* it actually updates
for service in service_names:
self.dispatch("red_api_tokens_update", service, MappingProxyType({}))
async def get_context(self, message, *, cls=commands.Context): async def get_context(self, message, *, cls=commands.Context):
return await super().get_context(message, cls=cls) return await super().get_context(message, cls=cls)