channel.messages: parse payload_json when creating message

This commit is contained in:
Luna 2019-02-19 18:43:23 -03:00
parent da7ef70458
commit d9283c92df
2 changed files with 8 additions and 4 deletions

View File

@ -336,10 +336,15 @@ async def _msg_input() -> tuple:
'tts': json.loads(form.get('tts', 'false')), 'tts': json.loads(form.get('tts', 'false')),
} }
payload_json = json.loads(form.get('payload_json', '{}'))
json_from_form.update(request_json) json_from_form.update(request_json)
json_from_form.update(payload_json)
files = await request.files files = await request.files
# we don't really care about the given fields on the files dict
# we don't really care about the given fields on the files dict, so
# we only extract the values
return json_from_form, [v for k, v in files.items()] return json_from_form, [v for k, v in files.items()]

View File

@ -88,7 +88,6 @@ class LitecordValidator(Validator):
return False return False
def _validate_type_voice_region(self, value: str) -> bool: def _validate_type_voice_region(self, value: str) -> bool:
# TODO: complete this list
return value.lower() in ('brazil', 'us-east', 'us-west', return value.lower() in ('brazil', 'us-east', 'us-west',
'us-south', 'russia') 'us-south', 'russia')
@ -394,6 +393,8 @@ MEMBER_UPDATE = {
} }
# NOTE: things such as payload_json are parsed at the handler
# for creating a message.
MESSAGE_CREATE = { MESSAGE_CREATE = {
'content': {'type': 'string', 'minlength': 0, 'maxlength': 2000}, 'content': {'type': 'string', 'minlength': 0, 'maxlength': 2000},
'nonce': {'type': 'snowflake', 'required': False}, 'nonce': {'type': 'snowflake', 'required': False},
@ -404,8 +405,6 @@ MESSAGE_CREATE = {
'schema': EMBED_OBJECT, 'schema': EMBED_OBJECT,
'required': False 'required': False
} }
# TODO: file, embed, payload_json
} }