Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
export: Stop outputting user_profile_email on upload records.
Alex Vandiverb2921ecb02c4
diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.pyindex 95d6ad01ee9..f55596d6d92 100644--- a/zerver/data_import/import_util.py+++ b/zerver/data_import/import_util.py@@ -142,7 +142,6 @@ def build_user_profile(def build_avatar(zulip_user_id: int,realm_id: int,- email: str,avatar_url: str,timestamp: Any,avatar_list: list[ZerverFieldsT],@@ -154,7 +153,6 @@ def build_avatar(avatar_version=1,user_profile_id=zulip_user_id,last_modified=timestamp,- user_profile_email=email,s3_path="",size="",)diff --git a/zerver/data_import/mattermost.py b/zerver/data_import/mattermost.pyindex 751903fda97..475b4929339 100644--- a/zerver/data_import/mattermost.py+++ b/zerver/data_import/mattermost.py@@ -354,7 +354,6 @@ def process_message_attachments(realm_id: int,message_id: int,user_id: int,- user_handler: UserHandler,zerver_attachment: list[ZerverFieldsT],uploads_list: list[ZerverFieldsT],mattermost_data_dir: str,@@ -398,7 +397,6 @@ def process_message_attachments(content_type=None,user_profile_id=user_id,last_modified=fileinfo["created"],- user_profile_email=user_handler.get_user(user_id=user_id)["email"],s3_path=s3_path,size=fileinfo["size"],)@@ -518,7 +516,6 @@ def process_raw_message_batch(realm_id=realm_id,message_id=message_id,user_id=sender_user_id,- user_handler=user_handler,zerver_attachment=zerver_attachment,uploads_list=uploads_list,mattermost_data_dir=mattermost_data_dir,diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.pyindex 143c34c18e5..8460b410309 100644--- a/zerver/data_import/rocketchat.py+++ b/zerver/data_import/rocketchat.py@@ -384,7 +384,6 @@ def process_message_attachment(realm_id: int,message_id: int,user_id: int,- user_handler: UserHandler,zerver_attachment: list[ZerverFieldsT],uploads_list: list[ZerverFieldsT],upload_id_to_upload_data_map: dict[str, dict[str, Any]],@@ -447,7 +446,6 @@ def process_message_attachment(content_type=upload["type"],user_profile_id=user_id,last_modified=fileinfo["created"],- user_profile_email=user_handler.get_user(user_id=user_id)["email"],s3_path=s3_path,size=fileinfo["size"],)@@ -537,7 +535,6 @@ def process_raw_message_batch(realm_id=realm_id,message_id=message_id,user_id=sender_user_id,- user_handler=user_handler,uploads_list=uploads_list,zerver_attachment=zerver_attachment,upload_id_to_upload_data_map=upload_id_to_upload_data_map,diff --git a/zerver/data_import/slack.py b/zerver/data_import/slack.pyindex ac04dd3a613..ce21115c7c4 100644--- a/zerver/data_import/slack.py+++ b/zerver/data_import/slack.py@@ -319,7 +319,7 @@ def users_to_zerver_userprofile(# ref: https://zulip.com/help/change-your-profile-pictureavatar_source, avatar_url = build_avatar_url(slack_user_id, user)if avatar_source == UserProfile.AVATAR_FROM_USER:- build_avatar(user_id, realm_id, email, avatar_url, timestamp, avatar_list)+ build_avatar(user_id, realm_id, avatar_url, timestamp, avatar_list)role = UserProfile.ROLE_MEMBERif get_owner(user):role = UserProfile.ROLE_REALM_OWNER@@ -1261,18 +1261,12 @@ def process_message_files(has_link = Truehas_image = "image" in fileinfo["mimetype"]- file_user = [- iterate_user for iterate_user in users if message["user"] == iterate_user["id"]- ]- file_user_email = get_user_email(file_user[0], domain_name)-s3_path, content_for_link = get_attachment_path_and_content(fileinfo, realm_id)markdown_links.append(content_for_link)build_uploads(slack_user_id_to_zulip_user_id[slack_user_id],realm_id,- file_user_email,fileinfo,s3_path,uploads_list,@@ -1401,7 +1395,6 @@ def build_reactions(def build_uploads(user_id: int,realm_id: int,- email: str,fileinfo: ZerverFieldsT,s3_path: str,uploads_list: list[ZerverFieldsT],@@ -1412,7 +1405,6 @@ def build_uploads(content_type=None,user_profile_id=user_id,last_modified=fileinfo["timestamp"],- user_profile_email=email,s3_path=s3_path,size=fileinfo["size"],)diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 178de7b0879..b2c49b3ade3 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -2116,14 +2116,12 @@ def _get_exported_s3_record(record["file_name"] = file_nameif "user_profile_id" in record:- user_profile = get_user_profile_by_id(int(record["user_profile_id"]))- record["user_profile_email"] = user_profile.email-# Fix the record idsrecord["user_profile_id"] = int(record["user_profile_id"])# A few early avatars don't have 'realm_id' on the object; fix their metadataif "realm_id" not in record:+ user_profile = get_user_profile_by_id(record["user_profile_id"])record["realm_id"] = user_profile.realm_idelse:# There are some rare cases in which 'user_profile_id' may not be present@@ -2263,7 +2261,6 @@ def export_uploads_from_local(record = dict(realm_id=attachment.realm_id,user_profile_id=attachment.owner.id,- user_profile_email=attachment.owner.email,s3_path=path_id,path=path_id,size=stat.st_size,@@ -2317,7 +2314,6 @@ def export_avatars_from_local(record = dict(realm_id=realm.id,user_profile_id=user.id,- user_profile_email=user.email,avatar_version=user.avatar_version,s3_path=fn,path=fn,diff --git a/zerver/tests/test_mattermost_importer.py b/zerver/tests/test_mattermost_importer.pyindex 97662f7887b..ab4a504999c 100644--- a/zerver/tests/test_mattermost_importer.py+++ b/zerver/tests/test_mattermost_importer.py@@ -500,7 +500,6 @@ class MatterMostImporter(ZulipTestCase):realm_id=3,message_id=1,user_id=2,- user_handler=user_handler,zerver_attachment=zerver_attachments,uploads_list=uploads_list,mattermost_data_dir=mattermost_data_dir,@@ -517,7 +516,7 @@ class MatterMostImporter(ZulipTestCase):self.assertTrue(zerver_attachments[0]["is_realm_public"])self.assert_length(uploads_list, 1)- self.assertEqual(uploads_list[0]["user_profile_email"], "[email protected]")+ self.assertEqual(uploads_list[0]["user_profile_id"], 2)attachment_path = self.fixture_file_name(mattermost_data["post"]["direct_post"][0]["attachments"][0]["path"],diff --git a/zerver/tests/test_rocketchat_importer.py b/zerver/tests/test_rocketchat_importer.pyindex 31f7324eaa9..be3d977bd1b 100644--- a/zerver/tests/test_rocketchat_importer.py+++ b/zerver/tests/test_rocketchat_importer.py@@ -876,7 +876,6 @@ class RocketChatImporter(ZulipTestCase):realm_id=3,message_id=1,user_id=3,- user_handler=user_handler,zerver_attachment=zerver_attachments,uploads_list=uploads_list,upload_id_to_upload_data_map=upload_id_to_upload_data_map,@@ -893,7 +892,7 @@ class RocketChatImporter(ZulipTestCase):self.assertTrue(zerver_attachments[0]["is_realm_public"])self.assert_length(uploads_list, 1)- self.assertEqual(uploads_list[0]["user_profile_email"], "[email protected]")+ self.assertEqual(uploads_list[0]["user_profile_id"], 3)attachment_out_path = os.path.join(output_dir, "uploads", zerver_attachments[0]["path_id"])self.assertTrue(os.path.exists(attachment_out_path))diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex acdca6a3a46..99ec7eebd01 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -2047,7 +2047,7 @@ by Pieterself.assertEqual(uploads_list[0]["s3_path"], image_path)self.assertEqual(uploads_list[0]["realm_id"], realm_id)- self.assertEqual(uploads_list[0]["user_profile_email"], "[email protected]")+ self.assertEqual(uploads_list[0]["user_profile_id"], alice_id)def test_bot_duplicates(self) -> None:self.assertEqual(