From 500579e957020f11e510512debf8102e86476f20 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Sun, 18 Nov 2018 01:20:02 -0300 Subject: [PATCH] channel.messages: fix mention affecting user_read_state --- litecord/blueprints/channel/messages.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/litecord/blueprints/channel/messages.py b/litecord/blueprints/channel/messages.py index d11eaa8..b961a39 100644 --- a/litecord/blueprints/channel/messages.py +++ b/litecord/blueprints/channel/messages.py @@ -191,13 +191,16 @@ async def create_message(channel_id): 'MESSAGE_CREATE', payload) if ctype == ChannelType.GUILD_TEXT: - for str_uid in payload['mentions']: - uid = int(str_uid) + for mention in payload['mentions']: + uid = int(mention['id']) + + print('updating user read state', repr(uid), repr(channel_id)) await app.db.execute(""" UPDATE user_read_state - SET mention_count += 1 - WHERE user_id = $1 AND channel_id = $2 + SET mention_count = mention_count + 1 + WHERE user_id = $1 + AND channel_id = $2 """, uid, channel_id) return jsonify(payload)