Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Remove `bot_creation_policy` setting.

Vector73a2c3138418ac
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 67371798d52..948e37a52cf 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -31,6 +31,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 create bot users who can only send messages in the organization
in addition to the users who are in `can_create_bots_group`.
+* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
+ `bot_creation_policy` property, as the permission to create bot users
+ in the organization is now controlled by two new realm settings,
+ `can_create_bots_group` and `can_create_write_only_bots_group`.
**Feature level 343**
diff --git a/zerver/migrations/0001_squashed_0569.py b/zerver/migrations/0001_squashed_0569.py
index fe76be43686..a36d6c9f1c4 100644
--- a/zerver/migrations/0001_squashed_0569.py
+++ b/zerver/migrations/0001_squashed_0569.py
@@ -22,6 +22,12 @@ import zerver.models.realms
import zerver.models.streams
+class LegacyBotCreationPolicyEnum(IntEnum):
+ EVERYONE = 1
+ LIMIT_GENERIC_BOTS = 2
+ ADMINS_ONLY = 3
+
+
class LegacyCommonMessagePolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
@@ -831,7 +837,7 @@ class Migration(migrations.Migration):
(
"bot_creation_policy",
models.PositiveSmallIntegerField(
- default=zerver.models.realms.BotCreationPolicyEnum["EVERYONE"]
+ default=LegacyBotCreationPolicyEnum["EVERYONE"]
),
),
("custom_upload_quota_gb", models.IntegerField(null=True)),
diff --git a/zerver/migrations/0659_remove_realm_bot_creation_policy.py b/zerver/migrations/0659_remove_realm_bot_creation_policy.py
new file mode 100644
index 00000000000..762623523b5
--- /dev/null
+++ b/zerver/migrations/0659_remove_realm_bot_creation_policy.py
@@ -0,0 +1,16 @@
+# Generated by Django 5.0.10 on 2025-01-27 11:24
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0658_alter_realm_can_create_bots_group_and_more"),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name="realm",
+ name="bot_creation_policy",
+ ),
+ ]
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 06673fe5c54..c0c98f99906 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -117,14 +117,6 @@ class CreateWebPublicStreamPolicyEnum(IntEnum):
OWNERS_ONLY = 7
-class BotCreationPolicyEnum(IntEnum):
- # This value is also being used in web/src/settings_bots.bot_creation_policy_values.
- # On updating it here, update it there as well.
- EVERYONE = 1
- LIMIT_GENERIC_BOTS = 2
- ADMINS_ONLY = 3
-
-
class MoveMessagesBetweenStreamsPolicyEnum(IntEnum):
MEMBERS_ONLY = 1
ADMINS_ONLY = 2
@@ -559,9 +551,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
}
plan_type = models.PositiveSmallIntegerField(default=PLAN_TYPE_SELF_HOSTED)
- bot_creation_policy = models.PositiveSmallIntegerField(default=BotCreationPolicyEnum.EVERYONE)
- BOT_CREATION_POLICY_TYPES = [field.value for field in BotCreationPolicyEnum]
-
UPLOAD_QUOTA_LIMITED = 5
UPLOAD_QUOTA_STANDARD_FREE = 50
custom_upload_quota_gb = models.IntegerField(null=True)
@@ -642,7 +631,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
allow_edit_history=bool,
allow_message_editing=bool,
avatar_changes_disabled=bool,
- bot_creation_policy=int,
default_code_block_language=str,
default_language=str,
description=str,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index b5b3196da8d..aaf727f5432 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -4452,11 +4452,6 @@ paths:
**Changes**: In Zulip 9.0 (feature level 243), the values in this
dictionary were changed. Previously, the values were a simple boolean
indicating whether the backend is enabled or not.
- bot_creation_policy:
- type: integer
- description: |
- The [policy](/api/roles-and-permissions#permission-levels)
- for which users can create bot users in this organization.
can_access_all_users_group:
allOf:
- $ref: "#/components/schemas/GroupSettingValue"
@@ -16735,13 +16730,6 @@ paths:
In Zulip 7.0 (feature level 159), `Nobody` was added as an option to
`edit_topic_policy` enum.
- $ref: "#/components/schemas/GroupSettingValue"
- realm_bot_creation_policy:
- type: integer
- description: |
- Present if `realm` is present in `fetch_event_types`.
-
- The [policy](/api/roles-and-permissions#permission-levels)
- for which users can create bot users in this organization.
realm_can_create_groups:
allOf:
- $ref: "#/components/schemas/GroupSettingValue"
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 66951a8b001..26d2fc8f3d9 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -3800,7 +3800,6 @@ class RealmPropertyActionTest(BaseAction):
name=["Zulip", "New Name"],
waiting_period_threshold=[1000, 2000],
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
- bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
video_chat_provider=[
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"],
],
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index 12ec5e89b85..b230aca5990 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -125,7 +125,6 @@ class HomeTest(ZulipTestCase):
"realm_authentication_methods",
"realm_available_video_chat_providers",
"realm_avatar_changes_disabled",
- "realm_bot_creation_policy",
"realm_bot_domain",
"realm_bots",
"realm_can_access_all_users_group",
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index 95e9f549293..62fd7790d45 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -946,7 +946,6 @@ class RealmTest(ZulipTestCase):
]
invalid_values = dict(
- bot_creation_policy=10,
message_retention_days=10,
video_chat_provider=10,
giphy_rating=10,
@@ -1881,7 +1880,6 @@ class RealmAPITest(ZulipTestCase):
name=["Zulip", "New Name"],
waiting_period_threshold=[10, 20],
wildcard_mention_policy=Realm.WILDCARD_MENTION_POLICY_TYPES,
- bot_creation_policy=Realm.BOT_CREATION_POLICY_TYPES,
video_chat_provider=[
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"],
Realm.VIDEO_CHAT_PROVIDERS["disabled"]["id"],
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 0bdd1950b12..b9a9df65ffd 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -46,12 +46,7 @@ from zerver.lib.user_groups import (
)
from zerver.lib.validator import check_capped_url, check_string
from zerver.models import Realm, RealmReactivationStatus, RealmUserDefault, UserProfile
-from zerver.models.realms import (
- BotCreationPolicyEnum,
- DigestWeekdayEnum,
- OrgTypeEnum,
- WildcardMentionPolicyEnum,
-)
+from zerver.models.realms import DigestWeekdayEnum, OrgTypeEnum, WildcardMentionPolicyEnum
from zerver.views.user_settings import (
check_information_density_setting_values,
check_settings_values,
@@ -131,7 +126,6 @@ def update_realm(
send_welcome_emails: Json[bool] | None = None,
digest_emails_enabled: Json[bool] | None = None,
message_content_allowed_in_email_notifications: Json[bool] | None = None,
- bot_creation_policy: Json[BotCreationPolicyEnum] | None = None,
can_create_bots_group: Json[GroupSettingChangeRequest] | None = None,
can_create_groups: Json[GroupSettingChangeRequest] | None = None,
can_create_public_channel_group: Json[GroupSettingChangeRequest] | None = None,