guilds: use to_update for j.icon

j.icon can be just a hash... so...
This commit is contained in:
Luna 2019-03-20 16:35:49 -03:00
parent 982ac6f05b
commit 56876c9dec
2 changed files with 6 additions and 8 deletions

View File

@ -284,13 +284,13 @@ async def _update_guild(guild_id):
if region is not None: if region is not None:
await _guild_update_region(guild_id, region) 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() # small guild to work with to_update()
guild = await app.storage.get_guild(guild_id) 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 to_update(j, guild, 'splash'):
if not await app.storage.has_feature(guild_id, 'INVITE_SPLASH'): if not await app.storage.has_feature(guild_id, 'INVITE_SPLASH'):
raise BadRequest('guild does not have INVITE_SPLASH feature') raise BadRequest('guild does not have INVITE_SPLASH feature')

View File

@ -279,10 +279,8 @@ GUILD_UPDATE = {
}, },
'region': {'type': 'voice_region', 'required': False, 'nullable': True}, 'region': {'type': 'voice_region', 'required': False, 'nullable': True},
'icon': {'type': 'b64_icon', 'required': False, 'nullable': True}, # all three can have hashes
'icon': {'type': 'string', 'required': False, 'nullable': True},
# TODO: does splash also respect when its just a string pointing to the
# hash, just like in USER_UPDATE.avatar?
'banner': {'type': 'string', 'required': False, 'nullable': True}, 'banner': {'type': 'string', 'required': False, 'nullable': True},
'splash': {'type': 'string', 'required': False, 'nullable': True}, 'splash': {'type': 'string', 'required': False, 'nullable': True},