mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
settings: Add backend to change allow_edit_history to integer field.
This commit implements the backend of migrating the `allow_edit_history` setting to `message_edit_history_visibility_policy`. This allows organizations, to have an intermediate setting to view only the "Moves" history of the messages. We still pass `realm_allow_edit_history` in `/register` response though for older clients with its value being set depending on the value of `realm_message_edit_history_visibility_policy`. We set `realm_allow_edit_history` to `False` if the `realm_message_edit_history_visibility_policy` is "None", and `True` for "Moves only" or "All" message edit history. Fixes part of #21398. Co-authored-by: Shlok Patel <shlokcpatel2001@gmail.com> Co-authored-by: Tim Abbott <tabbott@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
d9589eba2c
commit
d0c5c1cacb
@@ -97,6 +97,7 @@ from zerver.models.linkifiers import linkifiers_for_realm
|
||||
from zerver.models.realm_emoji import get_all_custom_emoji_for_realm
|
||||
from zerver.models.realm_playgrounds import get_realm_playgrounds
|
||||
from zerver.models.realms import (
|
||||
MessageEditHistoryVisibilityPolicyEnum,
|
||||
get_corresponding_policy_value_for_group_setting,
|
||||
get_realm_domains,
|
||||
get_realm_with_settings,
|
||||
@@ -474,6 +475,18 @@ def fetch_initial_state_data(
|
||||
)
|
||||
|
||||
state["realm_empty_topic_display_name"] = Message.EMPTY_TOPIC_FALLBACK_NAME
|
||||
|
||||
state["realm_allow_edit_history"] = (
|
||||
realm.message_edit_history_visibility_policy
|
||||
!= MessageEditHistoryVisibilityPolicyEnum.none.value
|
||||
)
|
||||
|
||||
state["realm_message_edit_history_visibility_policy"] = (
|
||||
MessageEditHistoryVisibilityPolicyEnum(
|
||||
realm.message_edit_history_visibility_policy
|
||||
).name
|
||||
)
|
||||
|
||||
if want("realm_user_settings_defaults"):
|
||||
realm_user_default = RealmUserDefault.objects.get(realm=realm)
|
||||
state["realm_user_settings_defaults"] = {}
|
||||
@@ -1311,6 +1324,11 @@ def apply_event(
|
||||
else state["server_jitsi_server_url"]
|
||||
)
|
||||
|
||||
if field == "realm_message_edit_history_visibility_policy":
|
||||
state["realm_allow_edit_history"] = (
|
||||
event["value"] != MessageEditHistoryVisibilityPolicyEnum.none.name
|
||||
)
|
||||
|
||||
elif event["op"] == "update_dict":
|
||||
for key, value in event["data"].items():
|
||||
if key == "max_file_upload_size_mib":
|
||||
|
||||
Reference in New Issue
Block a user