mirror of https://github.com/zulip/zulip.git
realm: Add time limit setting for moving messages between streams.
This commit adds "move_messages_between_streams_limit_seconds" setting which would be used to set a time limit to move messages between streams.
This commit is contained in:
parent
73f0eae394
commit
b919dfd489
|
@ -24,6 +24,8 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
||||||
`PATCH /realm`: Added new `move_messages_within_stream_limit_seconds` setting.
|
`PATCH /realm`: Added new `move_messages_within_stream_limit_seconds` setting.
|
||||||
|
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
||||||
|
`PATCH /realm`: Added new `move_messages_between_streams_limit_seconds` setting.
|
||||||
|
|
||||||
**Feature level 161**
|
**Feature level 161**
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Generated by Django 4.1.5 on 2023-01-26 14:28
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("zerver", "0424_realm_move_messages_within_stream_limit_seconds"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="realm",
|
||||||
|
name="move_messages_between_streams_limit_seconds",
|
||||||
|
field=models.PositiveIntegerField(default=604800, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -387,6 +387,10 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
||||||
default=DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS, null=True
|
default=DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS, null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
move_messages_between_streams_limit_seconds = models.PositiveIntegerField(
|
||||||
|
default=DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS, null=True
|
||||||
|
)
|
||||||
|
|
||||||
# Who in the organization is allowed to add custom emojis.
|
# Who in the organization is allowed to add custom emojis.
|
||||||
add_custom_emoji_policy = models.PositiveSmallIntegerField(default=POLICY_MEMBERS_ONLY)
|
add_custom_emoji_policy = models.PositiveSmallIntegerField(default=POLICY_MEMBERS_ONLY)
|
||||||
|
|
||||||
|
@ -736,6 +740,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
||||||
message_content_allowed_in_email_notifications=bool,
|
message_content_allowed_in_email_notifications=bool,
|
||||||
message_content_edit_limit_seconds=(int, type(None)),
|
message_content_edit_limit_seconds=(int, type(None)),
|
||||||
message_content_delete_limit_seconds=(int, type(None)),
|
message_content_delete_limit_seconds=(int, type(None)),
|
||||||
|
move_messages_between_streams_limit_seconds=(int, type(None)),
|
||||||
move_messages_within_stream_limit_seconds=(int, type(None)),
|
move_messages_within_stream_limit_seconds=(int, type(None)),
|
||||||
message_retention_days=(int, type(None)),
|
message_retention_days=(int, type(None)),
|
||||||
move_messages_between_streams_policy=int,
|
move_messages_between_streams_policy=int,
|
||||||
|
|
|
@ -3611,6 +3611,7 @@ paths:
|
||||||
value:
|
value:
|
||||||
description: |
|
description: |
|
||||||
The new value of the property.
|
The new value of the property.
|
||||||
|
nullable: true
|
||||||
oneOf:
|
oneOf:
|
||||||
- type: string
|
- type: string
|
||||||
- type: boolean
|
- type: boolean
|
||||||
|
@ -4046,6 +4047,20 @@ paths:
|
||||||
|
|
||||||
**Changes**: New in Zulip 7.0 (feature level 162). Previously, this
|
**Changes**: New in Zulip 7.0 (feature level 162). Previously, this
|
||||||
limit was always 72 hours.
|
limit was always 72 hours.
|
||||||
|
move_messages_between_streams_limit_seconds:
|
||||||
|
type: integer
|
||||||
|
nullable: true
|
||||||
|
description: |
|
||||||
|
Messages sent more than this many seconds ago cannot be moved between
|
||||||
|
streams by members with this organization's [message move
|
||||||
|
policy](/help/configure-who-can-edit-topics). This setting does not
|
||||||
|
affect moderators and administrators.
|
||||||
|
|
||||||
|
Will not be 0. A 'null' value means no limit: messages can be moved
|
||||||
|
regardless of how long ago they were sent.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 7.0 (feature level 162). Previously, it
|
||||||
|
was not possible to add a time limit for moving messages.
|
||||||
move_messages_between_streams_policy:
|
move_messages_between_streams_policy:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
|
@ -12232,6 +12247,22 @@ paths:
|
||||||
|
|
||||||
**Changes**: New in Zulip 7.0 (feature level 162). Previously, this
|
**Changes**: New in Zulip 7.0 (feature level 162). Previously, this
|
||||||
limit was always 72 hours.
|
limit was always 72 hours.
|
||||||
|
realm_move_messages_between_streams_limit_seconds:
|
||||||
|
type: integer
|
||||||
|
nullable: true
|
||||||
|
description: |
|
||||||
|
Present if `realm` is present in `fetch_event_types`.
|
||||||
|
|
||||||
|
Messages sent more than this many seconds ago cannot be moved between
|
||||||
|
streams by members with this organization's [message move
|
||||||
|
policy](/help/configure-who-can-edit-topics). This setting does not
|
||||||
|
affect moderators and administrators.
|
||||||
|
|
||||||
|
Will not be 0. A 'null' value means no limit: messages can be moved
|
||||||
|
regardless of how long ago they were sent.
|
||||||
|
|
||||||
|
**Changes**: New in Zulip 7.0 (feature level 162). Previously, it
|
||||||
|
was not possible to add a time limit for moving messages.
|
||||||
realm_community_topic_editing_limit_seconds:
|
realm_community_topic_editing_limit_seconds:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
|
|
|
@ -2605,6 +2605,7 @@ class RealmPropertyActionTest(BaseAction):
|
||||||
edit_topic_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
|
edit_topic_policy=Realm.COMMON_MESSAGE_POLICY_TYPES,
|
||||||
message_content_edit_limit_seconds=[1000, 1100, 1200, None],
|
message_content_edit_limit_seconds=[1000, 1100, 1200, None],
|
||||||
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
|
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
|
||||||
|
move_messages_between_streams_limit_seconds=[1000, 1100, 1200],
|
||||||
)
|
)
|
||||||
|
|
||||||
vals = test_values.get(name)
|
vals = test_values.get(name)
|
||||||
|
|
|
@ -159,6 +159,7 @@ class HomeTest(ZulipTestCase):
|
||||||
"realm_message_content_delete_limit_seconds",
|
"realm_message_content_delete_limit_seconds",
|
||||||
"realm_message_content_edit_limit_seconds",
|
"realm_message_content_edit_limit_seconds",
|
||||||
"realm_message_retention_days",
|
"realm_message_retention_days",
|
||||||
|
"realm_move_messages_between_streams_limit_seconds",
|
||||||
"realm_move_messages_between_streams_policy",
|
"realm_move_messages_between_streams_policy",
|
||||||
"realm_move_messages_within_stream_limit_seconds",
|
"realm_move_messages_within_stream_limit_seconds",
|
||||||
"realm_name",
|
"realm_name",
|
||||||
|
|
|
@ -640,6 +640,7 @@ class RealmTest(ZulipTestCase):
|
||||||
edit_topic_policy=10,
|
edit_topic_policy=10,
|
||||||
message_content_edit_limit_seconds=0,
|
message_content_edit_limit_seconds=0,
|
||||||
move_messages_within_stream_limit_seconds=0,
|
move_messages_within_stream_limit_seconds=0,
|
||||||
|
move_messages_between_streams_limit_seconds=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
# We need an admin user.
|
# We need an admin user.
|
||||||
|
@ -1178,6 +1179,7 @@ class RealmAPITest(ZulipTestCase):
|
||||||
edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
|
edit_topic_policy=Realm.EDIT_TOPIC_POLICY_TYPES,
|
||||||
message_content_edit_limit_seconds=[1000, 1100, 1200],
|
message_content_edit_limit_seconds=[1000, 1100, 1200],
|
||||||
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
|
move_messages_within_stream_limit_seconds=[1000, 1100, 1200],
|
||||||
|
move_messages_between_streams_limit_seconds=[1000, 1100, 1200],
|
||||||
)
|
)
|
||||||
|
|
||||||
vals = test_values.get(name)
|
vals = test_values.get(name)
|
||||||
|
@ -1326,6 +1328,14 @@ class RealmAPITest(ZulipTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(realm.move_messages_within_stream_limit_seconds, None)
|
self.assertEqual(realm.move_messages_within_stream_limit_seconds, None)
|
||||||
|
|
||||||
|
def test_update_realm_move_messages_between_streams_limit_seconds_unlimited_value(self) -> None:
|
||||||
|
realm = get_realm("zulip")
|
||||||
|
self.login("iago")
|
||||||
|
realm = self.update_with_api(
|
||||||
|
"move_messages_between_streams_limit_seconds", orjson.dumps("unlimited").decode()
|
||||||
|
)
|
||||||
|
self.assertEqual(realm.move_messages_between_streams_limit_seconds, None)
|
||||||
|
|
||||||
def test_update_realm_delete_own_message_policy(self) -> None:
|
def test_update_realm_delete_own_message_policy(self) -> None:
|
||||||
"""Tests updating the realm property 'delete_own_message_policy'."""
|
"""Tests updating the realm property 'delete_own_message_policy'."""
|
||||||
self.set_up_db("delete_own_message_policy", Realm.POLICY_EVERYONE)
|
self.set_up_db("delete_own_message_policy", Realm.POLICY_EVERYONE)
|
||||||
|
|
|
@ -151,6 +151,11 @@ def update_realm(
|
||||||
json_validator=check_string_or_int,
|
json_validator=check_string_or_int,
|
||||||
default=None,
|
default=None,
|
||||||
),
|
),
|
||||||
|
move_messages_between_streams_limit_seconds_raw: Optional[Union[int, str]] = REQ(
|
||||||
|
"move_messages_between_streams_limit_seconds",
|
||||||
|
json_validator=check_string_or_int,
|
||||||
|
default=None,
|
||||||
|
),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm = user_profile.realm
|
realm = user_profile.realm
|
||||||
|
|
||||||
|
@ -247,6 +252,23 @@ def update_realm(
|
||||||
"move_messages_within_stream_limit_seconds"
|
"move_messages_within_stream_limit_seconds"
|
||||||
] = move_messages_within_stream_limit_seconds
|
] = move_messages_within_stream_limit_seconds
|
||||||
|
|
||||||
|
move_messages_between_streams_limit_seconds: Optional[int] = None
|
||||||
|
if move_messages_between_streams_limit_seconds_raw is not None:
|
||||||
|
(
|
||||||
|
move_messages_between_streams_limit_seconds,
|
||||||
|
setting_value_changed,
|
||||||
|
) = parse_and_set_setting_value_if_required(
|
||||||
|
realm,
|
||||||
|
"move_messages_between_streams_limit_seconds",
|
||||||
|
move_messages_between_streams_limit_seconds_raw,
|
||||||
|
acting_user=user_profile,
|
||||||
|
)
|
||||||
|
|
||||||
|
if setting_value_changed:
|
||||||
|
data[
|
||||||
|
"move_messages_between_streams_limit_seconds"
|
||||||
|
] = move_messages_between_streams_limit_seconds
|
||||||
|
|
||||||
# The user of `locals()` here is a bit of a code smell, but it's
|
# The user of `locals()` here is a bit of a code smell, but it's
|
||||||
# restricted to the elements present in realm.property_types.
|
# restricted to the elements present in realm.property_types.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue