diff --git a/litecord/blueprints/channels.py b/litecord/blueprints/channels.py index d620268..88f78b7 100644 --- a/litecord/blueprints/channels.py +++ b/litecord/blueprints/channels.py @@ -422,7 +422,7 @@ async def _update_group_dm(channel_id: int, j: dict): UPDATE group_dm_channels SET icon = $1 WHERE id = $2 - """, new_icon, channel_id) + """, new_icon.icon_hash, channel_id) @bp.route('/', methods=['PUT', 'PATCH']) diff --git a/litecord/images.py b/litecord/images.py index 8c1012f..854e2b9 100644 --- a/litecord/images.py +++ b/litecord/images.py @@ -274,6 +274,9 @@ class IconManager: async def generic_get(self, scope, key, icon_hash, **kwargs) -> Icon: """Get any icon.""" + if icon_hash is None: + return None + log.debug('GET {} {} {}', scope, key, icon_hash) key = str(key) @@ -406,6 +409,12 @@ class IconManager: WHERE icon = $1 """, icon.icon_hash) + await self.storage.db.execute(""" + UPDATE group_dm_channels + SET icon = NULL + WHERE icon = $1 + """, icon.icon_hash) + await self.storage.db.execute(""" DELETE FROM icons WHERE hash = $1