From ed27bb605aac5f3c14e5b8f076cd0c028bbfbfd6 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 16 Feb 2019 23:15:29 -0300 Subject: [PATCH] add channel-icons icon scope handling --- litecord/blueprints/icons.py | 6 ++++++ litecord/images.py | 13 +++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/litecord/blueprints/icons.py b/litecord/blueprints/icons.py index 86662b2..9daa45b 100644 --- a/litecord/blueprints/icons.py +++ b/litecord/blueprints/icons.py @@ -76,3 +76,9 @@ async def _get_user_avatar(user_id, avatar_file): # @bp.route('/app-icons//.') async def get_app_icon(application_id, icon_hash, ext): pass + + +@bp.route('/channel-icons//', methods=['GET']) +async def _get_gdm_icon(guild_id: int, icon_file: str): + icon_hash, ext = splitext_(icon_file) + return await send_icon('channel-icons', guild_id, icon_hash, ext=ext) diff --git a/litecord/images.py b/litecord/images.py index bf3434c..8c1012f 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -161,21 +161,18 @@ def parse_data_uri(string) -> tuple: def _gen_update_sql(scope: str) -> str: field = { 'user': 'avatar', - 'guild': 'icon' + 'guild': 'icon', + 'channel-icons': 'icon', }[scope] table = { 'user': 'users', - 'guild': 'guilds' - }[scope] - - col = { - 'user': 'id', - 'guild': 'id' + 'guild': 'guilds', + 'channel-icons': 'group_dm_channels' }[scope] return f""" - SELECT {field} FROM {table} WHERE {col} = $1 + SELECT {field} FROM {table} WHERE id = $1 """