Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
import_utils: Fix history_public_to_subscribers being set incorrectly.
Mateusz Mandera04fdf3e4d98f
diff --git a/zerver/data_import/import_util.py b/zerver/data_import/import_util.pyindex 90d5ac1c276..f3548919d89 100644--- a/zerver/data_import/import_util.py+++ b/zerver/data_import/import_util.py@@ -441,6 +441,13 @@ def build_stream(invite_only: bool = False,stream_post_policy: int = 1,) -> ZerverFieldsT:++ # Other applications don't have the distinction of "private stream with public history"+ # vs "private stream with hidden history" - and we've traditionally imported private "streams"+ # of other products as private streams with hidden history.+ # So we can set the history_public_to_subscribers value based on the invite_only flag.+ history_public_to_subscribers = not invite_only+stream = Stream(name=name,deactivated=deactivated,@@ -450,6 +457,7 @@ def build_stream(invite_only=invite_only,id=stream_id,stream_post_policy=stream_post_policy,+ history_public_to_subscribers=history_public_to_subscribers,)stream_dict = model_to_dict(stream, exclude=["realm"])stream_dict["realm"] = realm_iddiff --git a/zerver/migrations/0390_fix_stream_history_public_to_subscribers.py b/zerver/migrations/0390_fix_stream_history_public_to_subscribers.pynew file mode 100644index 00000000000..b22ca5edd96--- /dev/null+++ b/zerver/migrations/0390_fix_stream_history_public_to_subscribers.py@@ -0,0 +1,23 @@+from django.db import migrations+from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.migrations.state import StateApps+++def fix_stream_history_public_to_subscribers(+ apps: StateApps, schema_editor: DatabaseSchemaEditor+) -> None:+ Stream = apps.get_model("zerver", "Stream")+ Stream.objects.filter(+ invite_only=False, is_in_zephyr_realm=False, history_public_to_subscribers=False+ ).update(history_public_to_subscribers=True)+++class Migration(migrations.Migration):++ dependencies = [+ ("zerver", "0389_userprofile_display_emoji_reaction_users"),+ ]++ operations = [+ migrations.RunPython(fix_stream_history_public_to_subscribers, elidable=True),+ ]diff --git a/zerver/tests/test_slack_importer.py b/zerver/tests/test_slack_importer.pyindex fa042c51bb9..52a6b3ba9b5 100644--- a/zerver/tests/test_slack_importer.py+++ b/zerver/tests/test_slack_importer.py@@ -684,6 +684,7 @@ class SlackImporter(ZulipTestCase):self.assertEqual(zerver_stream[0]["deactivated"], True)self.assertEqual(zerver_stream[0]["description"], "no purpose")self.assertEqual(zerver_stream[0]["invite_only"], False)+ self.assertEqual(zerver_stream[0]["history_public_to_subscribers"], True)self.assertEqual(zerver_stream[0]["realm"], realm_id)self.assertEqual(zerver_stream[2]["id"], test_added_channels[zerver_stream[2]["name"]][1])