mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
import_utils: Fix history_public_to_subscribers being set incorrectly.
history_public_to_subscribers wasn't explicitly set when creating streams via build_stream, thus relying on the model's default of False. This lead to public streams being created with that value set to False, which doesn't make sense. We can solve this by inferring the correct value based on invite_only in the build_stream funtion itself - rather than needing to add a flag argument to it. This commit also includes a migration to fix public stream with the wrong history_public_to_subscribers value. Fixes #21784.
This commit is contained in:
committed by
Tim Abbott
parent
bd072d79a4
commit
04fdf3e4d9
@@ -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),
|
||||
]
|
||||
Reference in New Issue
Block a user