From fedfc97c964f400ae2fdf1b24dc85919d5037cd8 Mon Sep 17 00:00:00 2001 From: slice Date: Sat, 21 Jul 2018 11:52:37 -0700 Subject: [PATCH] make nonces strings --- litecord/blueprints/channels.py | 12 ++++++++++-- litecord/schemas.py | 2 +- litecord/storage.py | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/litecord/blueprints/channels.py b/litecord/blueprints/channels.py index 8c362c6..2832aa1 100644 --- a/litecord/blueprints/channels.py +++ b/litecord/blueprints/channels.py @@ -108,8 +108,16 @@ async def create_message(channel_id): INSERT INTO messages (id, channel_id, author_id, content, tts, mention_everyone, nonce, message_type) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) - """, message_id, channel_id, user_id, j['content'], j.get('tts', False), - '@everyone' in j['content'], j.get('nonce', 0), MessageType.DEFAULT) + """, + message_id, + channel_id, + user_id, + j['content'], + j.get('tts', False), + '@everyone' in j['content'], + int(j.get('nonce', 0)), + MessageType.DEFAULT + ) # TODO: dispatch_channel payload = await app.storage.get_message(message_id) diff --git a/litecord/schemas.py b/litecord/schemas.py index 59a4daf..9aa8f6c 100644 --- a/litecord/schemas.py +++ b/litecord/schemas.py @@ -77,7 +77,7 @@ MEMBER_UPDATE = { MESSAGE_CREATE = { 'content': {'type': 'string', 'minlength': 1, 'maxlength': 2000}, - 'nonce': {'type': 'number', 'required': False}, + 'nonce': {'type': 'string', 'required': False}, 'tts': {'type': 'boolean', 'required': False}, # TODO: file, embed, payload_json diff --git a/litecord/storage.py b/litecord/storage.py index facf669..c608288 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -334,6 +334,7 @@ class Storage: return res = dict(row) + res['nonce'] = str(res['nonce']) res['timestamp'] = res['timestamp'].isoformat() res['type'] = res['message_type'] res.pop('message_type')