add channel-icons icon scope handling

This commit is contained in:
Luna 2019-02-16 23:15:29 -03:00
parent 0b99149053
commit ed27bb605a
2 changed files with 11 additions and 8 deletions

View File

@ -76,3 +76,9 @@ async def _get_user_avatar(user_id, avatar_file):
# @bp.route('/app-icons/<int:application_id>/<icon_hash>.<ext>')
async def get_app_icon(application_id, icon_hash, ext):
pass
@bp.route('/channel-icons/<int:channel_id>/<icon_file>', 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)

View File

@ -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
"""