From a852532c950948bc74d4d2bc4963b09892697230 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 18 Apr 2018 11:35:59 -0700 Subject: [PATCH] slack import: Refactor handling of dropped messages. This is a more coherent ordering, because some messages we skip lack a "text" attribute. --- zerver/lib/slack_data_to_zulip_data.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/zerver/lib/slack_data_to_zulip_data.py b/zerver/lib/slack_data_to_zulip_data.py index 11e4cfc3ca..fbbb4f4068 100755 --- a/zerver/lib/slack_data_to_zulip_data.py +++ b/zerver/lib/slack_data_to_zulip_data.py @@ -666,6 +666,12 @@ def channel_message_to_zerver_message(realm_id: int, users: List[ZerverFieldsT], # Ignore messages without user names # These are Sometimes produced by slack continue + if message.get('subtype') in [ + "channel_join", + "channel_leave", + "channel_name" + ]: + continue has_attachment = has_image = False try: @@ -689,14 +695,11 @@ def channel_message_to_zerver_message(realm_id: int, users: List[ZerverFieldsT], # Process different subtypes of slack messages if 'subtype' in message.keys(): subtype = message['subtype'] - if subtype in ["channel_join", "channel_leave", "channel_name"]: - continue - # Subtypes which have only the action in the message should # be rendered with '/me' in the content initially # For example "sh_room_created" has the message 'started a call' # which should be displayed as '/me started a call' - elif subtype in ["bot_add", "sh_room_created", "me_message"]: + if subtype in ["bot_add", "sh_room_created", "me_message"]: content = ('/me %s' % (content)) # For attachments with slack download link