From c4db99aa9ab8218c5c12eb554df1a72281307cde Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Thu, 11 Oct 2018 23:12:07 -0300 Subject: [PATCH] blueprints.channels: use ChannelDispatcher for CHANNEL_PINS_UPDATE and TYPING_START --- litecord/blueprints/channels.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/litecord/blueprints/channels.py b/litecord/blueprints/channels.py index e151391..cb375f6 100644 --- a/litecord/blueprints/channels.py +++ b/litecord/blueprints/channels.py @@ -488,11 +488,11 @@ async def delete_pin(channel_id, message_id): timestamp = snowflake_datetime(row['message_id']) - # TODO: dispatch_channel - await app.dispatcher.dispatch_guild(guild_id, 'CHANNEL_PINS_UPDATE', { - 'channel_id': str(channel_id), - 'last_pin_timestamp': timestamp.isoformat() - }) + await app.dispatcher.dispatch( + 'channel', channel_id, 'CHANNEL_PINS_UPDATE', { + 'channel_id': str(channel_id), + 'last_pin_timestamp': timestamp.isoformat() + }) return '', 204 @@ -500,16 +500,15 @@ async def delete_pin(channel_id, message_id): @bp.route('//typing', methods=['POST']) async def trigger_typing(channel_id): user_id = await token_check() - _ctype, guild_id = await channel_check(user_id, channel_id) + ctype, guild_id = await channel_check(user_id, channel_id) - # TODO: dispatch_channel - await app.dispatcher.dispatch_guild(guild_id, 'TYPING_START', { + await app.dispatcher.dispatch('channel', channel_id, 'TYPING_START', { 'channel_id': str(channel_id), 'user_id': str(user_id), 'timestamp': int(time.time()), # guild_id for lazy guilds - 'guild_id': str(guild_id), + 'guild_id': str(guild_id) if ctype == ChannelType.GUILD_TEXT else None, }) return '', 204