1
0
mirror of https://github.com/gryf/slack-backup.git synced 2025-12-17 11:30:25 +01:00

Fix for message comment.

If comment is sent by the user, different structure of the data is sent.
First of all, the type of this message is "message", but it contain
dictionary under 'comment' key, which can be confusing, which contain
needed data (like user id). For this kind of messages, in case of lack
of 'user' in main dict, dict['comment']['user'] will be used for getting
user identifier, while dict['text'] remains as a message text.
This commit is contained in:
2017-02-13 19:50:20 +01:00
parent 08a0a82435
commit 5f9f290ba4
2 changed files with 7 additions and 3 deletions

View File

@@ -147,8 +147,12 @@ class Client(object):
Create message with corresponding possible metadata, like reactions,
files etc.
"""
user = self.q(o.User).\
filter(o.User.slackid == data['user']).one()
try:
user = self.q(o.User).\
filter(o.User.slackid == data['user']).one()
except KeyError:
user = self.q(o.User).\
filter(o.User.slackid == data['comment']['user']).one()
if data['type'] == 'message' and not data['text'].strip():
logging.info("Skipping message from `%s' since it's empty",