From 7b4aaabcbfbc87510adb4f54cbe7e60b7ebf64a3 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 5 Mar 2019 16:30:38 -0300 Subject: [PATCH] storage: better fix for message.webhook_id the old fix only works for the return value in message create, where as it should be in Storage.get_message instead so that the bug doesn't happen to the other routes --- litecord/blueprints/channel/messages.py | 3 --- litecord/storage.py | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index dfba47b..41850e2 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -408,9 +408,6 @@ async def _create_message(channel_id): await _dm_pre_dispatch(channel_id, user_id) await _dm_pre_dispatch(channel_id, guild_id) - if payload['webhook_id'] == None: - payload.pop('webhook_id', None) - await app.dispatcher.dispatch('channel', channel_id, 'MESSAGE_CREATE', payload) diff --git a/litecord/storage.py b/litecord/storage.py index d23eacb..74a6be5 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -763,12 +763,13 @@ class Storage: return res - async def _inject_author(self, res): + async def _inject_author(self, res: dict): """Inject a pseudo-user object when the message is made by a webhook.""" author_id, webhook_id = res['author_id'], res['webhook_id'] if author_id is not None: res['author'] = await self.get_user(res['author_id']) + res.pop('webhook_id') elif webhook_id is not None: res['author'] = { 'id': webhook_id,