diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 23c6600115..b959587d22 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -26,6 +26,14 @@ format used by the Zulip server that they are interacting with. [`GET /events`](/api/get-events): Added `can_create_private_channel_group` realm setting, which is a [group-setting value](/api/group-setting-values) describing the set of users with permission to create private channels. +* `PATCH /realm`, [`GET /events`](/api/get-events): Removed + `create_private_stream_policy` property, as the permission to create private + channels is now controlled by `can_create_private_channel_group` setting. +* [`POST /register`](/api/register-queue): `realm_create_private_stream_policy` + field is deprecated, having been replaced by `can_create_private_channel_group`. + Notably, this backwards-compatible `realm_create_private_stream_policy` value + now contains the superset of the true value that best approximates the actual + permission setting. **Feature level 265** diff --git a/version.py b/version.py index 6d3244f7de..304d80a80e 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3" # Changes should be accompanied by documentation explaining what the # new level means in api_docs/changelog.md, as well as "**Changes**" # entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 265 +API_FEATURE_LEVEL = 266 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 3531a6e1a9..5e79c43bb7 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -294,6 +294,11 @@ def fetch_initial_state_data( realm, "can_create_public_channel_group", Realm.COMMON_POLICY_TYPES ) ) + state["realm_create_private_stream_policy"] = ( + get_corresponding_policy_value_for_group_setting( + realm, "can_create_private_channel_group", Realm.COMMON_POLICY_TYPES + ) + ) # Most state is handled via the property_types framework; # these manual entries are for those realm settings that don't @@ -1252,6 +1257,13 @@ def apply_event( ) state["can_create_public_streams"] = user_profile.has_permission(key) else: + state["realm_create_private_stream_policy"] = ( + get_corresponding_policy_value_for_group_setting( + user_profile.realm, + "can_create_private_channel_group", + Realm.COMMON_POLICY_TYPES, + ) + ) state["can_create_private_streams"] = user_profile.has_permission(key) state["can_create_streams"] = ( diff --git a/zerver/migrations/0540_remove_realm_create_private_stream_policy.py b/zerver/migrations/0540_remove_realm_create_private_stream_policy.py new file mode 100644 index 0000000000..07fa4ef40d --- /dev/null +++ b/zerver/migrations/0540_remove_realm_create_private_stream_policy.py @@ -0,0 +1,16 @@ +# Generated by Django 5.0.6 on 2024-06-17 14:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("zerver", "0539_alter_realm_can_create_private_channel_group"), + ] + + operations = [ + migrations.RemoveField( + model_name="realm", + name="create_private_stream_policy", + ), + ] diff --git a/zerver/models/realms.py b/zerver/models/realms.py index eb0aed089e..b59fb4626d 100644 --- a/zerver/models/realms.py +++ b/zerver/models/realms.py @@ -303,9 +303,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub ) # Who in the organization is allowed to create streams. - create_private_stream_policy = models.PositiveSmallIntegerField( - default=CommonPolicyEnum.MEMBERS_ONLY - ) create_web_public_stream_policy = models.PositiveSmallIntegerField( default=CreateWebPublicStreamPolicyEnum.OWNERS_ONLY ) @@ -647,7 +644,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub allow_message_editing=bool, avatar_changes_disabled=bool, bot_creation_policy=int, - create_private_stream_policy=int, create_web_public_stream_policy=int, default_code_block_language=str, default_language=str, diff --git a/zerver/models/users.py b/zerver/models/users.py index 70a7255ad3..f9105ab1cf 100644 --- a/zerver/models/users.py +++ b/zerver/models/users.py @@ -752,7 +752,6 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): "can_create_private_channel_group", "can_create_public_channel_group", "create_multiuse_invite_group", - "create_private_stream_policy", "create_web_public_stream_policy", "delete_own_message_policy", "edit_topic_policy", diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 82481c9a89..53bc56cbcd 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -4259,14 +4259,6 @@ paths: **Changes**: New in Zulip 9.0 (feature level 266). Previously `realm_create_private_stream_policy` field used to control the permission to create private channels. - create_private_stream_policy: - type: integer - description: | - The [policy](/api/roles-and-permissions#permission-levels) - for which users can create private channels in this organization. - - **Changes**: Before Zulip 5.0 (feature level 102), permission to - create channels was controlled by the `create_stream_policy` setting. create_web_public_stream_policy: type: integer description: | @@ -15309,17 +15301,28 @@ paths: [calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member realm_create_private_stream_policy: type: integer + deprecated: true description: | Present if `realm` is present in `fetch_event_types`. - The [policy][permission-level] for which users can create private channels - in this organization. + A deprecated representation of a superset of the users who + have permission to create private channels in the organization, + available for backwards-compatibility. Clients should use + `can_create_private_channel_group` instead. + + It is an enum with the following possible values, corresponding + to roles/system groups: - 1 = Members only - 2 = Admins only - 3 = [Full members][calc-full-member] only - 4 = Admins and moderators only + **Changes**: Deprecated in Zulip 9.0 (feature level 266) and + replaced by `realm_can_create_private_channel_group`, which + supports finer resolution of configurations, resulting in this + property being inaccurate following that transition. + **Changes**: Before Zulip 5.0 (feature level 102), permission to create channels was controlled by the `realm_create_stream_policy` setting. diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index a3b2d5b560..d4928702a1 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -3399,7 +3399,6 @@ class RealmPropertyActionTest(BaseAction): message_retention_days=[10, 20], name=["Zulip", "New Name"], waiting_period_threshold=[1000, 2000], - create_private_stream_policy=Realm.COMMON_POLICY_TYPES, create_web_public_stream_policy=Realm.CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES, invite_to_stream_policy=Realm.COMMON_POLICY_TYPES, private_message_policy=Realm.PRIVATE_MESSAGE_POLICY_TYPES, diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 4758b0c839..9525ff59ce 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -111,7 +111,6 @@ class RealmTest(ZulipTestCase): ) self.assertEqual(realm.can_create_public_channel_group_id, admins_group.id) - self.assertEqual(realm.create_private_stream_policy, CommonPolicyEnum.MEMBERS_ONLY) self.assertEqual(realm.invite_to_realm_policy, InviteToRealmPolicyEnum.ADMINS_ONLY) self.assertEqual( realm.move_messages_between_streams_policy, @@ -132,7 +131,6 @@ class RealmTest(ZulipTestCase): ) self.assertEqual(realm.can_create_public_channel_group_id, admins_group.id) - self.assertEqual(realm.create_private_stream_policy, CommonPolicyEnum.MEMBERS_ONLY) self.assertEqual(realm.invite_to_realm_policy, InviteToRealmPolicyEnum.ADMINS_ONLY) self.assertEqual( realm.move_messages_between_streams_policy, @@ -761,7 +759,6 @@ class RealmTest(ZulipTestCase): invalid_values = dict( bot_creation_policy=10, - create_private_stream_policy=10, create_web_public_stream_policy=10, invite_to_stream_policy=10, message_retention_days=10, @@ -1480,7 +1477,6 @@ class RealmAPITest(ZulipTestCase): message_retention_days=[10, 20], name=["Zulip", "New Name"], waiting_period_threshold=[10, 20], - create_private_stream_policy=Realm.COMMON_POLICY_TYPES, create_web_public_stream_policy=Realm.CREATE_WEB_PUBLIC_STREAM_POLICY_TYPES, user_group_edit_policy=Realm.COMMON_POLICY_TYPES, private_message_policy=Realm.PRIVATE_MESSAGE_POLICY_TYPES, diff --git a/zerver/views/realm.py b/zerver/views/realm.py index 22df2ed76b..1945735fa0 100644 --- a/zerver/views/realm.py +++ b/zerver/views/realm.py @@ -149,7 +149,6 @@ def update_realm( bot_creation_policy: Optional[Json[BotCreationPolicyEnum]] = None, can_create_public_channel_group: Optional[Json[GroupSettingChangeRequest]] = None, can_create_private_channel_group: Optional[Json[GroupSettingChangeRequest]] = None, - create_private_stream_policy: Optional[Json[CommonPolicyEnum]] = None, create_web_public_stream_policy: Optional[Json[CreateWebPublicStreamPolicyEnum]] = None, invite_to_stream_policy: Optional[Json[CommonPolicyEnum]] = None, move_messages_between_streams_policy: Optional[