Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
export: Prompt for confirmation if a consent message is involved.
Alex Vandiver15d7e7a6fdd1
diff --git a/zerver/management/commands/export.py b/zerver/management/commands/export.pyindex 129ad6883d0..36caad3a6c6 100644--- a/zerver/management/commands/export.py+++ b/zerver/management/commands/export.py@@ -152,6 +152,10 @@ class Command(ZulipBaseCommand):user_count = UserProfile.objects.filter(realm_id=realm.id).count()print(f"\033[94mNumber of users that reacted outbox:\033[0m {len(reactions)} / {user_count} total users\n")+ proceed = input("Continue? [y/N] ")+ if proceed.lower() not in ('y', 'yes'):+ raise CommandError("Aborting!")+if output_dir is None:output_dir = tempfile.mkdtemp(prefix="zulip-export-")else:diff --git a/zerver/tests/test_management_commands.py b/zerver/tests/test_management_commands.pyindex 7bb495d2f8f..7ab909407eb 100644--- a/zerver/tests/test_management_commands.py+++ b/zerver/tests/test_management_commands.py@@ -447,12 +447,14 @@ class TestExport(ZulipTestCase):do_add_reaction(self.example_user("hamlet"), message, "outbox", "1f4e4", Reaction.UNICODE_EMOJI)with patch("zerver.management.commands.export.export_realm_wrapper") as m, \- patch('builtins.print') as mock_print:+ patch('builtins.print') as mock_print, \+ patch('builtins.input', return_value='y') as mock_input:call_command(self.COMMAND_NAME, "-r=zulip", f"--consent-message-id={message.id}")m.assert_called_once_with(realm=realm, public_only=False, consent_message_id=message.id,delete_after_upload=False, threads=mock.ANY, output_dir=mock.ANY,percent_callback=mock.ANY,upload=False)+ mock_input.assert_called_once_with('Continue? [y/N] ')self.assertEqual(mock_print.mock_calls, [call('\033[94mExporting realm\033[0m: zulip'),