From 8accc60ca720d1ea69315d46b133eb7781a962f7 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sat, 13 Oct 2018 20:04:42 +0000 Subject: [PATCH] import_util: Support multiple message ids for attachments. --- zerver/data_import/import_util.py | 6 +++--- zerver/data_import/slack.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.py index e8cab884de..a2c5daf891 100644 --- a/zerver/data_import/import_util.py +++ b/zerver/data_import/import_util.py @@ -5,7 +5,7 @@ import shutil import logging import os -from typing import List, Dict, Any, Optional +from typing import List, Dict, Any, Optional, Set from django.forms.models import model_to_dict from zerver.models import Realm, RealmEmoji, Subscription, Recipient, \ @@ -295,7 +295,7 @@ def build_message(subject: str, pub_date: float, message_id: int, content: str, return zulip_message_dict -def build_attachment(realm_id: int, message_id: int, attachment_id: int, +def build_attachment(realm_id: int, message_ids: Set[int], attachment_id: int, user_id: int, fileinfo: ZerverFieldsT, s3_path: str, zerver_attachment: List[ZerverFieldsT]) -> None: """ @@ -313,7 +313,7 @@ def build_attachment(realm_id: int, message_id: int, attachment_id: int, attachment_dict = model_to_dict(attachment, exclude=['owner', 'messages', 'realm']) attachment_dict['owner'] = user_id - attachment_dict['messages'] = [message_id] + attachment_dict['messages'] = list(message_ids) attachment_dict['realm'] = realm_id zerver_attachment.append(attachment_dict) diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.py index a273d230da..67d7cd49e2 100755 --- a/zerver/data_import/slack.py +++ b/zerver/data_import/slack.py @@ -614,7 +614,7 @@ def channel_message_to_zerver_message(realm_id: int, users: List[ZerverFieldsT], uploads_list) attachment_id = attachment_id_count - build_attachment(realm_id, message_id, attachment_id, added_users[user], + build_attachment(realm_id, {message_id}, attachment_id, added_users[user], fileinfo, s3_path, zerver_attachment) attachment_id_count += 1 # For attachments with link not from slack