From 1ba1408b01038da303b073ded3f9b09205492e0f Mon Sep 17 00:00:00 2001 From: Vector73 Date: Sun, 27 Oct 2024 22:04:34 +0530 Subject: [PATCH] settings: Remove `edit_topic_policy` setting. Removed `edit_topic_policy` property, as the permission to move messages between topcis is now controlled by `can_move_messages_between_topics_group` setting. --- api_docs/changelog.md | 4 ++ zerver/actions/realm_settings.py | 1 - zerver/lib/event_schema.py | 9 ---- zerver/lib/events.py | 4 -- zerver/migrations/0001_squashed_0569.py | 13 +++-- .../0621_remove_realm_edit_topic_policy.py | 16 ++++++ zerver/models/realms.py | 15 ------ zerver/models/users.py | 1 - zerver/openapi/zulip.yaml | 50 ++----------------- zerver/tests/test_events.py | 2 - zerver/tests/test_home.py | 1 - zerver/tests/test_realm.py | 2 - zerver/views/realm.py | 2 - 13 files changed, 35 insertions(+), 85 deletions(-) create mode 100644 zerver/migrations/0621_remove_realm_edit_topic_policy.py diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 3d852599e6..30a0dbeae5 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -28,6 +28,10 @@ format used by the Zulip server that they are interacting with. [group-setting value](/api/group-setting-values) describing the set of users with permission to move messages from one topic to another within a channel in the organization. +* `PATCH /realm`, [`GET /events`](/api/get-events): Removed + `edit_topic_policy` property, as the permission to move messages between + topics in the organization is now controlled by + `can_move_messages_between_topics_group` setting. **Feature level 315** diff --git a/zerver/actions/realm_settings.py b/zerver/actions/realm_settings.py index babcce7055..7d06ab8257 100644 --- a/zerver/actions/realm_settings.py +++ b/zerver/actions/realm_settings.py @@ -82,7 +82,6 @@ def do_set_realm_property( # These settings have a different event format due to their history. message_edit_settings = [ "allow_message_editing", - "edit_topic_policy", "message_content_edit_limit_seconds", ] if name in message_edit_settings: diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index 046aea37f8..5d47f3505b 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -1039,12 +1039,6 @@ message_content_edit_limit_seconds_data = DictType( ] ) -edit_topic_policy_data = DictType( - required_keys=[ - ("edit_topic_policy", int), - ] -) - night_logo_data = DictType( required_keys=[ ("night_logo_url", str), @@ -1096,7 +1090,6 @@ update_dict_data = UnionType( [ allow_message_editing_data, authentication_data, - edit_topic_policy_data, icon_data, logo_data, message_content_edit_limit_seconds_data, @@ -1131,8 +1124,6 @@ def check_realm_update_dict( sub_type = allow_message_editing_data elif "message_content_edit_limit_seconds" in event["data"]: sub_type = message_content_edit_limit_seconds_data - elif "edit_topic_policy" in event["data"]: - sub_type = edit_topic_policy_data elif "authentication_methods" in event["data"]: sub_type = authentication_data elif any( diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 8d7b23d4e7..5d4e2b7be1 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -96,7 +96,6 @@ 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 ( - EditTopicPolicyEnum, get_corresponding_policy_value_for_group_setting, get_realm_domains, get_realm_with_settings, @@ -332,9 +331,6 @@ def fetch_initial_state_data( state["realm_allow_message_editing"] = ( False if user_profile is None else realm.allow_message_editing ) - state["realm_edit_topic_policy"] = ( - EditTopicPolicyEnum.ADMINS_ONLY if user_profile is None else realm.edit_topic_policy - ) # This setting determines whether to send presence and also # whether to display of users list in the right sidebar; we diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py index 346f64db5d..3c323e9dbc 100644 --- a/zerver/migrations/0001_squashed_0569.py +++ b/zerver/migrations/0001_squashed_0569.py @@ -30,6 +30,15 @@ class LegacyCommonMessagePolicyEnum(IntEnum): EVERYONE = 5 +class LegacyEditTopicPolicyEnum(IntEnum): + MEMBERS_ONLY = 1 + ADMINS_ONLY = 2 + FULL_MEMBERS_ONLY = 3 + MODERATORS_ONLY = 4 + EVERYONE = 5 + NOBODY = 6 + + def get_fts_sql() -> str: if settings.POSTGRESQL_MISSING_DICTIONARIES: fts_sql = """ @@ -743,9 +752,7 @@ class Migration(migrations.Migration): ), ( "edit_topic_policy", - models.PositiveSmallIntegerField( - default=zerver.models.realms.EditTopicPolicyEnum["EVERYONE"] - ), + models.PositiveSmallIntegerField(default=LegacyEditTopicPolicyEnum["EVERYONE"]), ), ( "invite_to_realm_policy", diff --git a/zerver/migrations/0621_remove_realm_edit_topic_policy.py b/zerver/migrations/0621_remove_realm_edit_topic_policy.py new file mode 100644 index 0000000000..6cc29718cf --- /dev/null +++ b/zerver/migrations/0621_remove_realm_edit_topic_policy.py @@ -0,0 +1,16 @@ +# Generated by Django 5.0.9 on 2024-10-27 16:28 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("zerver", "0620_alter_realm_can_move_messages_between_topics_group"), + ] + + operations = [ + migrations.RemoveField( + model_name="realm", + name="edit_topic_policy", + ), + ] diff --git a/zerver/models/realms.py b/zerver/models/realms.py index 4d36a452fa..9b5a0fc4d8 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -106,15 +106,6 @@ class CommonPolicyEnum(IntEnum): MODERATORS_ONLY = 4 -class EditTopicPolicyEnum(IntEnum): - MEMBERS_ONLY = 1 - ADMINS_ONLY = 2 - FULL_MEMBERS_ONLY = 3 - MODERATORS_ONLY = 4 - EVERYONE = 5 - NOBODY = 6 - - class InviteToRealmPolicyEnum(IntEnum): MEMBERS_ONLY = 1 ADMINS_ONLY = 2 @@ -268,8 +259,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub field.value for field in CreateWebPublicStreamPolicyEnum ] - EDIT_TOPIC_POLICY_TYPES = [field.value for field in EditTopicPolicyEnum] - DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS = 7 * SECONDS_PER_DAY move_messages_within_stream_limit_seconds = models.PositiveIntegerField( @@ -311,9 +300,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub "UserGroup", on_delete=models.RESTRICT, related_name="+" ) - # Who in the organization is allowed to edit topics of any message. - edit_topic_policy = models.PositiveSmallIntegerField(default=EditTopicPolicyEnum.EVERYONE) - # Who in the organization is allowed to invite other users to organization. invite_to_realm_policy = models.PositiveSmallIntegerField( default=InviteToRealmPolicyEnum.MEMBERS_ONLY @@ -654,7 +640,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub digest_emails_enabled=bool, digest_weekday=int, disallow_disposable_email_addresses=bool, - edit_topic_policy=int, email_changes_disabled=bool, emails_restricted_to_domains=bool, enable_guest_user_indicator=bool, diff --git a/zerver/models/users.py b/zerver/models/users.py index a6806dee56..4efe99a9b1 100644 --- a/zerver/models/users.py +++ b/zerver/models/users.py @@ -817,7 +817,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): from zerver.models import Realm if policy_name not in Realm.REALM_PERMISSION_GROUP_SETTINGS and policy_name not in [ - "edit_topic_policy", "invite_to_stream_policy", "invite_to_realm_policy", ]: diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index db526a7692..bc313f4399 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -4357,7 +4357,11 @@ paths: description: | An object containing the properties that have changed. - **Changes**: In Zulip 7.0 (feature level 183), the + **Changes**: In Zulip 10.0 (feature level 316), `edit_topic_policy` + property was removed and replaced by `can_move_messages_between_topics_group` + realm setting. + + In Zulip 7.0 (feature level 183), the `community_topic_editing_limit_seconds` property was removed. It was documented as potentially returned as a changed property in this event, but in fact it was only ever returned in the @@ -4633,27 +4637,6 @@ paths: description: | Whether the organization disallows disposable email addresses. - edit_topic_policy: - type: integer - description: | - The [policy][permission-level] for which users can edit topics of any message. - - - 1 = Members only - - 2 = Admins only - - 3 = [Full members][calc-full-member] only - - 4 = Moderators only - - 5 = Everyone - - 6 = Nobody - - See [`PATCH /messages/{message_id}`](/api/update-message) for details and history - of how message editing permissions work. - - **Changes**: Nobody added as an option in Zulip 7.0 (feature level 159). - - New in Zulip 5.0 (feature level 75). - - [permission-level]: /api/roles-and-permissions#permission-levels - [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member email_changes_disabled: type: boolean description: | @@ -16928,29 +16911,6 @@ paths: history of how message editing permissions work. [config-message-editing]: /help/restrict-message-editing-and-deletion - realm_edit_topic_policy: - type: integer - description: | - Present if `realm` is present in `fetch_event_types`. - - The [policy][permission-level] for which users can edit topics of any message. - - - 1 = Members only - - 2 = Admins only - - 3 = [Full members][calc-full-member] only - - 4 = Moderators only - - 5 = Everyone - - 6 = Nobody - - See [`PATCH /messages/{message_id}`](/api/update-message) for details and - history of how message editing permissions work. - - **Changes**: Nobody added as an option in Zulip 7.0 (feature level 159). - - New in Zulip 5.0 (feature level 75). - - [permission-level]: /api/roles-and-permissions#permission-levels - [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member realm_message_content_edit_limit_seconds: type: integer nullable: true diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index c58cc06903..b90eabcb6d 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -3743,7 +3743,6 @@ class RealmPropertyActionTest(BaseAction): default_code_block_language=["python", "javascript"], message_content_delete_limit_seconds=[1000, 1100, 1200], invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, - edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES, message_content_edit_limit_seconds=[1000, 1100, 1200, None], move_messages_within_stream_limit_seconds=[1000, 1100, 1200], move_messages_between_streams_limit_seconds=[1000, 1100, 1200], @@ -3804,7 +3803,6 @@ class RealmPropertyActionTest(BaseAction): if name in [ "allow_message_editing", - "edit_topic_policy", "message_content_edit_limit_seconds", ]: check_realm_update_dict("events[0]", events[0]) diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 15e91e134f..16313727cc 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -156,7 +156,6 @@ class HomeTest(ZulipTestCase): "realm_direct_message_permission_group", "realm_disallow_disposable_email_addresses", "realm_domains", - "realm_edit_topic_policy", "realm_email_auth_enabled", "realm_email_changes_disabled", "realm_emails_restricted_to_domains", diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 6c09c8504f..dcac8f603c 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -849,7 +849,6 @@ class RealmTest(ZulipTestCase): message_content_delete_limit_seconds=-10, wildcard_mention_policy=10, invite_to_realm_policy=10, - edit_topic_policy=10, message_content_edit_limit_seconds=0, move_messages_within_stream_limit_seconds=0, move_messages_between_streams_limit_seconds=0, @@ -1697,7 +1696,6 @@ class RealmAPITest(ZulipTestCase): ], message_content_delete_limit_seconds=[1000, 1100, 1200], invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES, - edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES, message_content_edit_limit_seconds=[1000, 1100, 1200], move_messages_within_stream_limit_seconds=[1000, 1100, 1200], move_messages_between_streams_limit_seconds=[1000, 1100, 1200], diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 397afde2ad..6aa7f5e4ed 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -52,7 +52,6 @@ from zerver.models.realms import ( BotCreationPolicyEnum, CommonPolicyEnum, DigestWeekdayEnum, - EditTopicPolicyEnum, InviteToRealmPolicyEnum, OrgTypeEnum, WildcardMentionPolicyEnum, @@ -116,7 +115,6 @@ def update_realm( ApiParamConfig("message_content_delete_limit_seconds"), ] = None, allow_message_editing: Json[bool] | None = None, - edit_topic_policy: Json[EditTopicPolicyEnum] | None = None, mandatory_topics: Json[bool] | None = None, message_content_edit_limit_seconds_raw: Annotated[ Json[int | str] | None, ApiParamConfig("message_content_edit_limit_seconds")