mirror of https://github.com/zulip/zulip.git
settings: Remove `delete_own_message_policy` realm property.
Removed `delete_own_message_policy` realm property as the permission to delete own messages is controlled by `can_delete_own_message_group` setting.
This commit is contained in:
parent
28c7a04734
commit
0cd51f2fea
|
@ -27,6 +27,9 @@ format used by the Zulip server that they are interacting with.
|
|||
Added `can_delete_own_message_group` realm setting which is a
|
||||
[group-setting value](/api/group-setting-values) describing the set of users
|
||||
with permission to delete the messages that they have sent in the organization.
|
||||
* `PATCH /realm`, [`GET /events`](/api/get-events): Removed
|
||||
`delete_own_message_policy` property, as the permission to delete own messages
|
||||
is now controlled by `can_delete_own_message_group` setting.
|
||||
|
||||
**Feature level 290**
|
||||
|
||||
|
|
|
@ -215,7 +215,6 @@ export function dispatch_normal_event(event) {
|
|||
invite_to_stream_policy: noop,
|
||||
default_code_block_language: noop,
|
||||
default_language: noop,
|
||||
delete_own_message_policy: noop,
|
||||
description: noop,
|
||||
digest_emails_enabled: noop,
|
||||
digest_weekday: noop,
|
||||
|
|
|
@ -123,7 +123,6 @@ function set_page_params_no_edit_restrictions() {
|
|||
realm.realm_message_content_edit_limit_seconds = null;
|
||||
realm.realm_allow_edit_history = true;
|
||||
realm.realm_message_content_delete_limit_seconds = null;
|
||||
realm.realm_delete_own_message_policy = 1;
|
||||
realm.realm_enable_read_receipts = true;
|
||||
realm.realm_edit_topic_policy = 5;
|
||||
realm.realm_move_messages_within_stream_limit_seconds = null;
|
||||
|
|
|
@ -443,8 +443,6 @@ function test_discard_changes_button(discard_changes) {
|
|||
realm.realm_edit_topic_policy = settings_config.common_message_policy_values.by_everyone.code;
|
||||
realm.realm_allow_message_editing = true;
|
||||
realm.realm_message_content_edit_limit_seconds = 3600;
|
||||
realm.realm_delete_own_message_policy =
|
||||
settings_config.common_message_policy_values.by_everyone.code;
|
||||
realm.realm_message_content_delete_limit_seconds = 120;
|
||||
|
||||
const $allow_edit_history = $("#id_realm_allow_edit_history").prop("checked", false);
|
||||
|
|
|
@ -94,7 +94,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 (
|
||||
CommonMessagePolicyEnum,
|
||||
EditTopicPolicyEnum,
|
||||
get_corresponding_policy_value_for_group_setting,
|
||||
get_realm_domains,
|
||||
|
@ -333,11 +332,6 @@ def fetch_initial_state_data(
|
|||
state["realm_edit_topic_policy"] = (
|
||||
EditTopicPolicyEnum.ADMINS_ONLY if user_profile is None else realm.edit_topic_policy
|
||||
)
|
||||
state["realm_delete_own_message_policy"] = (
|
||||
CommonMessagePolicyEnum.ADMINS_ONLY
|
||||
if user_profile is None
|
||||
else realm.delete_own_message_policy
|
||||
)
|
||||
|
||||
# This setting determines whether to send presence and also
|
||||
# whether to display of users list in the right sidebar; we
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Generated by Django 5.0.7 on 2024-09-09 12:53
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0581_alter_realm_can_delete_own_message_group"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="realm",
|
||||
name="delete_own_message_policy",
|
||||
),
|
||||
]
|
|
@ -318,11 +318,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 delete messages they themselves sent.
|
||||
delete_own_message_policy = models.PositiveSmallIntegerField(
|
||||
default=CommonMessagePolicyEnum.EVERYONE
|
||||
)
|
||||
|
||||
# Who in the organization is allowed to edit topics of any message.
|
||||
edit_topic_policy = models.PositiveSmallIntegerField(default=EditTopicPolicyEnum.EVERYONE)
|
||||
|
||||
|
@ -657,7 +652,6 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
|||
bot_creation_policy=int,
|
||||
default_code_block_language=str,
|
||||
default_language=str,
|
||||
delete_own_message_policy=int,
|
||||
description=str,
|
||||
digest_emails_enabled=bool,
|
||||
digest_weekday=int,
|
||||
|
|
|
@ -15698,26 +15698,6 @@ paths:
|
|||
setting controlled this permission; `true` corresponded to `Everyone`, and
|
||||
`false` to `Admins`.
|
||||
- $ref: "#/components/schemas/GroupSettingValue"
|
||||
realm_delete_own_message_policy:
|
||||
type: integer
|
||||
description: |
|
||||
Present if `realm` is present in `fetch_event_types`.
|
||||
|
||||
The [policy][permission-level] defining which users can delete
|
||||
messages that they had sent.
|
||||
|
||||
- 1 = Members only
|
||||
- 2 = Admins only
|
||||
- 3 = [Full members][calc-full-member] only
|
||||
- 4 = Admins and moderators only
|
||||
- 5 = Everyone
|
||||
|
||||
**Changes**: New in Zulip 5.0 (feature level 101), replacing the
|
||||
previous `allow_message_deleting` boolean;
|
||||
`true` corresponded to `everyone`, and `false` to `admins only`.
|
||||
|
||||
[permission-level]: /api/roles-and-permissions#permission-levels
|
||||
[calc-full-member]: /api/roles-and-permissions#determining-if-a-user-is-a-full-member
|
||||
realm_bot_creation_policy:
|
||||
type: integer
|
||||
description: |
|
||||
|
|
|
@ -3497,7 +3497,6 @@ class RealmPropertyActionTest(BaseAction):
|
|||
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
|
||||
move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES,
|
||||
add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
|
||||
delete_own_message_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
|
||||
edit_topic_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
|
||||
message_content_edit_limit_seconds=[1000, 1100, 1200, None],
|
||||
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
|
||||
|
|
|
@ -145,7 +145,6 @@ class HomeTest(ZulipTestCase):
|
|||
"realm_default_language",
|
||||
"realm_default_stream_groups",
|
||||
"realm_default_streams",
|
||||
"realm_delete_own_message_policy",
|
||||
"realm_description",
|
||||
"realm_digest_emails_enabled",
|
||||
"realm_digest_weekday",
|
||||
|
|
|
@ -63,7 +63,6 @@ from zerver.models import (
|
|||
from zerver.models.groups import SystemGroups
|
||||
from zerver.models.realm_audit_logs import AuditLogEventType
|
||||
from zerver.models.realms import (
|
||||
CommonMessagePolicyEnum,
|
||||
CommonPolicyEnum,
|
||||
InviteToRealmPolicyEnum,
|
||||
MoveMessagesBetweenStreamsPolicyEnum,
|
||||
|
@ -857,7 +856,6 @@ class RealmTest(ZulipTestCase):
|
|||
invite_to_realm_policy=10,
|
||||
move_messages_between_streams_policy=10,
|
||||
add_custom_emoji_policy=10,
|
||||
delete_own_message_policy=10,
|
||||
edit_topic_policy=10,
|
||||
message_content_edit_limit_seconds=0,
|
||||
move_messages_within_stream_limit_seconds=0,
|
||||
|
@ -1709,7 +1707,6 @@ class RealmAPITest(ZulipTestCase):
|
|||
invite_to_realm_policy=Realm.INVITE_TO_REALM_POLICY_TYPES,
|
||||
move_messages_between_streams_policy=Realm.MOVE_MESSAGES_BETWEEN_STREAMS_POLICY_TYPES,
|
||||
add_custom_emoji_policy=Realm.COMMON_POLICY_TYPES,
|
||||
delete_own_message_policy=Realm.COMMON_MESSAGE_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],
|
||||
|
@ -2351,51 +2348,6 @@ class RealmAPITest(ZulipTestCase):
|
|||
)
|
||||
self.assertEqual(realm.move_messages_between_streams_limit_seconds, None)
|
||||
|
||||
def test_update_realm_delete_own_message_policy(self) -> None:
|
||||
"""Tests updating the realm property 'delete_own_message_policy'."""
|
||||
realm = get_realm("zulip")
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.EVERYONE)
|
||||
realm = self.update_with_api(
|
||||
"delete_own_message_policy", CommonMessagePolicyEnum.ADMINS_ONLY
|
||||
)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.ADMINS_ONLY)
|
||||
self.assertEqual(realm.message_content_delete_limit_seconds, 600)
|
||||
realm = self.update_with_api("delete_own_message_policy", CommonMessagePolicyEnum.EVERYONE)
|
||||
realm = self.update_with_api("message_content_delete_limit_seconds", 100)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.EVERYONE)
|
||||
self.assertEqual(realm.message_content_delete_limit_seconds, 100)
|
||||
realm = self.update_with_api(
|
||||
"message_content_delete_limit_seconds", orjson.dumps("unlimited").decode()
|
||||
)
|
||||
self.assertEqual(realm.message_content_delete_limit_seconds, None)
|
||||
realm = self.update_with_api("message_content_delete_limit_seconds", 600)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.EVERYONE)
|
||||
self.assertEqual(realm.message_content_delete_limit_seconds, 600)
|
||||
realm = self.update_with_api(
|
||||
"delete_own_message_policy", CommonMessagePolicyEnum.MODERATORS_ONLY
|
||||
)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.MODERATORS_ONLY)
|
||||
realm = self.update_with_api(
|
||||
"delete_own_message_policy", CommonMessagePolicyEnum.FULL_MEMBERS_ONLY
|
||||
)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.FULL_MEMBERS_ONLY)
|
||||
realm = self.update_with_api(
|
||||
"delete_own_message_policy", CommonMessagePolicyEnum.MEMBERS_ONLY
|
||||
)
|
||||
self.assertEqual(realm.delete_own_message_policy, CommonMessagePolicyEnum.MEMBERS_ONLY)
|
||||
|
||||
# Test that 0 is invalid value.
|
||||
req = dict(message_content_delete_limit_seconds=orjson.dumps(0).decode())
|
||||
result = self.client_patch("/json/realm", req)
|
||||
self.assert_json_error(result, "Bad value for 'message_content_delete_limit_seconds': 0")
|
||||
|
||||
# Test that only "unlimited" string is valid and others are invalid.
|
||||
req = dict(message_content_delete_limit_seconds=orjson.dumps("invalid").decode())
|
||||
result = self.client_patch("/json/realm", req)
|
||||
self.assert_json_error(
|
||||
result, "Bad value for 'message_content_delete_limit_seconds': invalid"
|
||||
)
|
||||
|
||||
def do_test_changing_settings_by_owners_only(self, setting_name: str) -> None:
|
||||
bool_tests: list[bool] = [False, True]
|
||||
test_values: dict[str, Any] = dict(
|
||||
|
|
|
@ -50,7 +50,6 @@ from zerver.lib.validator import check_capped_url, check_string
|
|||
from zerver.models import Realm, RealmReactivationStatus, RealmUserDefault, UserProfile
|
||||
from zerver.models.realms import (
|
||||
BotCreationPolicyEnum,
|
||||
CommonMessagePolicyEnum,
|
||||
CommonPolicyEnum,
|
||||
DigestWeekdayEnum,
|
||||
EditTopicPolicyEnum,
|
||||
|
@ -115,7 +114,6 @@ def update_realm(
|
|||
add_custom_emoji_policy: Json[CommonPolicyEnum] | None = None,
|
||||
can_delete_any_message_group: Json[GroupSettingChangeRequest] | None = None,
|
||||
can_delete_own_message_group: Json[GroupSettingChangeRequest] | None = None,
|
||||
delete_own_message_policy: Json[CommonMessagePolicyEnum] | None = None,
|
||||
message_content_delete_limit_seconds_raw: Annotated[
|
||||
Json[int | str] | None,
|
||||
ApiParamConfig("message_content_delete_limit_seconds"),
|
||||
|
|
Loading…
Reference in New Issue