slack importer: Add '/me' in content for specific subtypes.

This commit is contained in:
Rhea Parekh
2018-03-20 23:56:35 +05:30
committed by Tim Abbott
parent f29a1918f3
commit e7291148e8

View File

@@ -596,11 +596,19 @@ def channel_message_to_zerver_message(realm_id: int, users: List[ZerverFieldsT],
recipient_id = added_recipient[message['channel_name']] recipient_id = added_recipient[message['channel_name']]
message_id = message_id_list[message_id_count] message_id = message_id_list[message_id_count]
# Process different subtypes of slack messages
if 'subtype' in message.keys(): if 'subtype' in message.keys():
subtype = message['subtype'] subtype = message['subtype']
if subtype in ["channel_join", "channel_leave", "channel_name"]: if subtype in ["channel_join", "channel_leave", "channel_name"]:
continue 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"]:
content = ('/me %s' % (content))
# For attachments with slack download link # For attachments with slack download link
elif subtype == "file_share" and 'files.slack.com' in message['file']['url_private']: elif subtype == "file_share" and 'files.slack.com' in message['file']['url_private']:
fileinfo = message['file'] fileinfo = message['file']