From 010410c849f9c4795ec68b17a068996e8d110a15 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 17 Oct 2024 11:31:13 -0700 Subject: [PATCH] rocketchat: Validate custom emoji before larger data sets. This is a data set that's relatively likely to have weird failures, and also likely to be fairly small. --- zerver/data_import/rocketchat.py | 20 ++++++++++---------- zerver/tests/test_rocketchat_importer.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.py index 925c5f57d7..f5affb643b 100644 --- a/zerver/data_import/rocketchat.py +++ b/zerver/data_import/rocketchat.py @@ -1107,6 +1107,16 @@ def do_convert_data(rocketchat_data_dir: str, output_dir: str) -> None: user_id_mapper=user_id_mapper, ) + rocketchat_emoji_data = rocketchat_data_to_dict(rocketchat_data_dir, ["custom_emoji"])[ + "custom_emoji" + ] + zerver_realmemoji = build_custom_emoji( + realm_id=realm_id, + custom_emoji_data=rocketchat_emoji_data, + output_dir=output_dir, + ) + realm["zerver_realmemoji"] = zerver_realmemoji + room_id_to_room_map: dict[str, dict[str, Any]] = {} team_id_to_team_map: dict[str, dict[str, Any]] = {} dsc_id_to_dsc_map: dict[str, dict[str, Any]] = {} @@ -1181,16 +1191,6 @@ def do_convert_data(rocketchat_data_dir: str, output_dir: str) -> None: ) realm["zerver_subscription"] = zerver_subscription - rocketchat_emoji_data = rocketchat_data_to_dict(rocketchat_data_dir, ["custom_emoji"])[ - "custom_emoji" - ] - zerver_realmemoji = build_custom_emoji( - realm_id=realm_id, - custom_emoji_data=rocketchat_emoji_data, - output_dir=output_dir, - ) - realm["zerver_realmemoji"] = zerver_realmemoji - subscriber_map = make_subscriber_map( zerver_subscription=zerver_subscription, ) diff --git a/zerver/tests/test_rocketchat_importer.py b/zerver/tests/test_rocketchat_importer.py index 1fa8b83bc1..92e3a164e9 100644 --- a/zerver/tests/test_rocketchat_importer.py +++ b/zerver/tests/test_rocketchat_importer.py @@ -908,9 +908,9 @@ class RocketChatImporter(ZulipTestCase): self.assertEqual( info_log.output, [ - "INFO:root:Direct message group channel found. UIDs: ['LdBZ7kPxtKESyHPEe', 'M2sXGqoQRJQwQoXY2', 'os6N2Xg2JkNMCSW9Z']", "INFO:root:Starting to process custom emoji", "INFO:root:Done processing emoji", + "INFO:root:Direct message group channel found. UIDs: ['LdBZ7kPxtKESyHPEe', 'M2sXGqoQRJQwQoXY2', 'os6N2Xg2JkNMCSW9Z']", "INFO:root:skipping direct messages discussion mention: Discussion with Hermione", ], )