guilds: add support for icon hash for j.splash

- guilds: fix guild icon being set to j.splash
 - schemas: handle splash being icon hash
This commit is contained in:
Luna 2019-03-15 04:39:09 -03:00
parent 5bfafa2a29
commit 5c0dfcc9b1
2 changed files with 6 additions and 6 deletions

View File

@ -286,17 +286,17 @@ async def _update_guild(guild_id):
if 'icon' in j: if 'icon' in j:
await _guild_update_icon( await _guild_update_icon(
'guild', guild_id, j['splash'], size=(128, 128)) 'guild', guild_id, j['icon'], size=(128, 128))
if 'splash' in j: # small guild to work with to_update()
guild = await app.storage.get_guild(guild_id)
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')
await _guild_update_icon('splash', guild_id, j['splash']) await _guild_update_icon('splash', guild_id, j['splash'])
# small guild to work with to_update()
guild = await app.storage.get_guild(guild_id)
if to_update(j, guild, 'banner'): if to_update(j, guild, 'banner'):
if not await app.storage.has_feature(guild_id, 'VERIFIED'): if not await app.storage.has_feature(guild_id, 'VERIFIED'):
raise BadRequest('guild is not verified') raise BadRequest('guild is not verified')

View File

@ -280,11 +280,11 @@ 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}, 'icon': {'type': 'b64_icon', 'required': False, 'nullable': True},
'splash': {'type': 'b64_icon', 'required': False, 'nullable': True},
# TODO: does splash also respect when its just a string pointing to the # TODO: does splash also respect when its just a string pointing to the
# hash, just like in USER_UPDATE.avatar? # 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},
'description': { 'description': {
'type': 'string', 'required': False, 'type': 'string', 'required': False,