Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

user export: Add reactions.

Steve Howell2a73964e16be
diff --git a/zerver/lib/export.py b/zerver/lib/export.py
index c07735ca542..aa9cfa92612 100644
--- a/zerver/lib/export.py
+++ b/zerver/lib/export.py
@@ -2026,6 +2026,13 @@ def get_single_user_config() -> Config:
custom_fetch=custom_fetch_realm_audit_logs_for_user,
)
+ Config(
+ table="zerver_reaction",
+ model=Reaction,
+ normal_parent=user_profile_config,
+ include_rows="user_profile_id__in",
+ )
+
add_user_profile_child_configs(user_profile_config)
return user_profile_config
diff --git a/zerver/tests/test_import_export.py b/zerver/tests/test_import_export.py
index 04f68eecada..f31336b31ce 100644
--- a/zerver/tests/test_import_export.py
+++ b/zerver/tests/test_import_export.py
@@ -640,6 +640,21 @@ class ImportExportTest(ZulipTestCase):
self.assertIn(pm_d_msg_id, exported_msg_ids)
def test_export_single_user(self) -> None:
+ hamlet = self.example_user("hamlet")
+ cordelia = self.example_user("cordelia")
+
+ smile_message_id = self.send_stream_message(hamlet, "Denmark", "SMILE!")
+
+ check_add_reaction(
+ user_profile=cordelia,
+ message_id=smile_message_id,
+ emoji_name="smile",
+ emoji_code=None,
+ reaction_type=None,
+ )
+ reaction = Reaction.objects.order_by("id").last()
+ assert reaction
+
output_dir = self._make_output_dir()
cordelia = self.example_user("cordelia")
@@ -672,6 +687,19 @@ class ImportExportTest(ZulipTestCase):
exported_messages_recipient = self.get_set(messages["zerver_message"], "recipient")
self.assertIn(list(exported_messages_recipient)[0], exported_recipient_id)
+ (exported_reaction,) = user["zerver_reaction"]
+ self.assertEqual(
+ exported_reaction,
+ dict(
+ id=reaction.id,
+ user_profile=cordelia.id,
+ emoji_name="smile",
+ reaction_type="unicode_emoji",
+ emoji_code=reaction.emoji_code,
+ message=smile_message_id,
+ ),
+ )
+
"""
Tests for import_realm
"""