From 4e7dcbeefc2f01077d0d942a18fa5077917d391b Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Mon, 19 Nov 2018 04:25:15 -0300 Subject: [PATCH] channel.messages: update edited_at properly - storage: give str guild_id on message objects --- litecord/blueprints/channel/messages.py | 11 ++++++++++- litecord/storage.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index 84b6b2e..fa54916 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -269,9 +269,18 @@ async def edit_message(channel_id, message_id): # TODO: update embed + # only set new timestamp upon actual update + if updated: + await app.db.execute(""" + UPDATE messages + SET edited_at = (now() at time zone 'utc') + WHERE id = $1 + """, message_id) + message = await app.storage.get_message(message_id, user_id) - # only dispatch MESSAGE_UPDATE if we actually had any update to start with + # only dispatch MESSAGE_UPDATE if any update + # actually happened if updated: await app.dispatcher.dispatch('channel', channel_id, 'MESSAGE_UPDATE', message) diff --git a/litecord/storage.py b/litecord/storage.py index abf4b59..b8455d8 100644 --- a/litecord/storage.py +++ b/litecord/storage.py @@ -700,7 +700,7 @@ class Storage: # only insert when the channel # is actually from a guild. if guild_id: - res['guild_id'] = guild_id + res['guild_id'] = str(guild_id) return res