From 122e11c6788677df60c196ff0f05100d278cf0a8 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Sat, 25 Jan 2020 22:47:21 -0800 Subject: [PATCH] slack import: Fix handling of messages sent by user U00. --- zerver/data_import/slack.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py index 261e295ec1..d6db317cb2 100755 --- a/zerver/data_import/slack.py +++ b/zerver/data_import/slack.py @@ -626,15 +626,24 @@ def get_messages_iterator(slack_data_dir: str, added_channels: Dict[str, Any], messages_for_one_day = [] # type: List[ZerverFieldsT] for dir_path in all_json_names[json_name]: message_dir = os.path.join(dir_path, json_name) - messages = get_data_file(message_dir) dir_name = os.path.basename(dir_path) - for message in messages: + messages = [] + for message in get_data_file(message_dir): + if message.get('user') == 'U00': + # Skip messages involving the the "U00" user, + # which is apparently used in some channel rename + # messages. It's likely just the result of some + # bug in Slack's export system. Arguably we could + # change this to point to slackbot instead, but + # skipping those messages is simpler. + continue if dir_name in added_channels: message['channel_name'] = dir_name elif dir_name in added_mpims: message['mpim_name'] = dir_name elif dir_name in dm_members: message['pm_name'] = dir_name + messages.append(message) messages_for_one_day += messages # we sort the messages according to the timestamp to show messages with