import_util: Support multiple message ids for attachments.

This commit is contained in:
Steve Howell 2018-10-13 20:04:42 +00:00 committed by Tim Abbott
parent 23d7b3d2cc
commit 8accc60ca7
2 changed files with 4 additions and 4 deletions

View File

@ -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)

View File

@ -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