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

Fix for handling messages of different types than 'message'

This commit is contained in:
2017-08-06 09:19:17 +02:00
parent 5f9f290ba4
commit 64d4b09468
3 changed files with 11 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ except ImportError:
setup(name="slack-backup",
packages=["slack_backup"],
version="0.4.5",
version="0.5",
description="Make copy of slack converstaions",
author="Roman Dobosz",
author_email="gryf73@gmail.com",

View File

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

View File

@@ -324,7 +324,10 @@ MSGS = {'messages': [{"type": "message",
"<https://esm64.slack.com/files/name2/F3405RRB5/"
"screenshot.png|Screenshot.png>",
"ts": "1478107371.000052",
"upload": True}],
"upload": True},
{'type': 'something else',
'ts': '1502003415232.000001',
"wibblr": True}],
"ok": True,
"latest": "1479501075.000020",
"has_more": True}
@@ -389,7 +392,7 @@ class TestApiCalls(TestCase):
"C00000001").one()
msg, ts = cl._channels_history(channel, 0)
self.assertEqual(len(msg), 5)
self.assertEqual(len(msg), 6)
self.assertEqual(ts, '1479501074.000032')
msg, ts = cl._channels_history(channel, ts)