From 56876c9decfcfe20b98d070299860bebc854b449 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 20 Mar 2019 16:35:49 -0300 Subject: [PATCH] guilds: use to_update for j.icon j.icon can be just a hash... so... --- litecord/blueprints/guilds.py | 8 ++++---- litecord/schemas.py | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index c4675b8..0ad3a67 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -284,13 +284,13 @@ async def _update_guild(guild_id): if region is not None: await _guild_update_region(guild_id, region) - if 'icon' in j: - await _guild_update_icon( - 'guild', guild_id, j['icon'], size=(128, 128)) - # small guild to work with to_update() guild = await app.storage.get_guild(guild_id) + if to_update(j, guild, 'icon'): + await _guild_update_icon( + 'guild', guild_id, j['icon'], size=(128, 128)) + if to_update(j, guild, 'splash'): if not await app.storage.has_feature(guild_id, 'INVITE_SPLASH'): raise BadRequest('guild does not have INVITE_SPLASH feature') diff --git a/litecord/schemas.py b/litecord/schemas.py index 980a7ff..855673a 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -279,10 +279,8 @@ GUILD_UPDATE = { }, 'region': {'type': 'voice_region', 'required': False, 'nullable': True}, - 'icon': {'type': 'b64_icon', 'required': False, 'nullable': True}, - - # TODO: does splash also respect when its just a string pointing to the - # hash, just like in USER_UPDATE.avatar? + # all three can have hashes + 'icon': {'type': 'string', 'required': False, 'nullable': True}, 'banner': {'type': 'string', 'required': False, 'nullable': True}, 'splash': {'type': 'string', 'required': False, 'nullable': True},