mirror of https://github.com/zulip/zulip.git
realm: Add time limit setting for moving message within stream.
This commit adds "move_messages_within_streams_limit_seconds" setting which would be used to set a time limit to move messages within stream.
This commit is contained in:
parent
5b1f6a696e
commit
73f0eae394
|
@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
|
|||
|
||||
## Changes in Zulip 7.0
|
||||
|
||||
**Feature level 162**
|
||||
|
||||
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
||||
`PATCH /realm`: Added new `move_messages_within_stream_limit_seconds` setting.
|
||||
|
||||
**Feature level 161**
|
||||
|
||||
* [`PATCH /streams/{stream_id}`](/api/update-stream): Added
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.1.5 on 2023-01-26 14:27
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0423_fix_email_gateway_attachment_owner"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="realm",
|
||||
name="move_messages_within_stream_limit_seconds",
|
||||
field=models.PositiveIntegerField(default=604800, null=True),
|
||||
),
|
||||
]
|
|
@ -115,6 +115,8 @@ from zerver.lib.validator import (
|
|||
MAX_TOPIC_NAME_LENGTH = 60
|
||||
MAX_LANGUAGE_ID_LENGTH: int = 50
|
||||
|
||||
SECONDS_PER_DAY = 86400
|
||||
|
||||
STREAM_NAMES = TypeVar("STREAM_NAMES", Sequence[str], AbstractSet[str])
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
@ -379,6 +381,12 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
|||
|
||||
DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS = 259200
|
||||
|
||||
DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS = 7 * SECONDS_PER_DAY
|
||||
|
||||
move_messages_within_stream_limit_seconds = models.PositiveIntegerField(
|
||||
default=DEFAULT_MOVE_MESSAGE_LIMIT_SECONDS, null=True
|
||||
)
|
||||
|
||||
# Who in the organization is allowed to add custom emojis.
|
||||
add_custom_emoji_policy = models.PositiveSmallIntegerField(default=POLICY_MEMBERS_ONLY)
|
||||
|
||||
|
@ -728,6 +736,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
|||
message_content_allowed_in_email_notifications=bool,
|
||||
message_content_edit_limit_seconds=(int, type(None)),
|
||||
message_content_delete_limit_seconds=(int, type(None)),
|
||||
move_messages_within_stream_limit_seconds=(int, type(None)),
|
||||
message_retention_days=(int, type(None)),
|
||||
move_messages_between_streams_policy=int,
|
||||
name=str,
|
||||
|
|
|
@ -4032,6 +4032,20 @@ paths:
|
|||
|
||||
**Changes**: No limit was represented using the
|
||||
special value `0` before Zulip 6.0 (feature level 138).
|
||||
move_messages_within_stream_limit_seconds:
|
||||
type: integer
|
||||
nullable: true
|
||||
description: |
|
||||
Messages sent more than this many seconds ago cannot be moved within a
|
||||
stream 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, this
|
||||
limit was always 72 hours.
|
||||
move_messages_between_streams_policy:
|
||||
type: integer
|
||||
description: |
|
||||
|
@ -12202,6 +12216,22 @@ paths:
|
|||
|
||||
**Changes**: No limit was represented using the
|
||||
special value `0` before Zulip 6.0 (feature level 138).
|
||||
realm_move_messages_within_stream_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 within a
|
||||
stream 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, this
|
||||
limit was always 72 hours.
|
||||
realm_community_topic_editing_limit_seconds:
|
||||
type: integer
|
||||
description: |
|
||||
|
|
|
@ -2604,6 +2604,7 @@ class RealmPropertyActionTest(BaseAction):
|
|||
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],
|
||||
)
|
||||
|
||||
vals = test_values.get(name)
|
||||
|
|
|
@ -160,6 +160,7 @@ class HomeTest(ZulipTestCase):
|
|||
"realm_message_content_edit_limit_seconds",
|
||||
"realm_message_retention_days",
|
||||
"realm_move_messages_between_streams_policy",
|
||||
"realm_move_messages_within_stream_limit_seconds",
|
||||
"realm_name",
|
||||
"realm_name_changes_disabled",
|
||||
"realm_night_logo_source",
|
||||
|
|
|
@ -639,6 +639,7 @@ class RealmTest(ZulipTestCase):
|
|||
delete_own_message_policy=10,
|
||||
edit_topic_policy=10,
|
||||
message_content_edit_limit_seconds=0,
|
||||
move_messages_within_stream_limit_seconds=0,
|
||||
)
|
||||
|
||||
# We need an admin user.
|
||||
|
@ -1176,6 +1177,7 @@ class RealmAPITest(ZulipTestCase):
|
|||
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],
|
||||
)
|
||||
|
||||
vals = test_values.get(name)
|
||||
|
@ -1316,6 +1318,14 @@ class RealmAPITest(ZulipTestCase):
|
|||
self.assertIn("ignored_parameters_unsupported", result)
|
||||
self.assertEqual(result["ignored_parameters_unsupported"], ["emoji_set"])
|
||||
|
||||
def test_update_realm_move_messages_within_stream_limit_seconds_unlimited_value(self) -> None:
|
||||
realm = get_realm("zulip")
|
||||
self.login("iago")
|
||||
realm = self.update_with_api(
|
||||
"move_messages_within_stream_limit_seconds", orjson.dumps("unlimited").decode()
|
||||
)
|
||||
self.assertEqual(realm.move_messages_within_stream_limit_seconds, None)
|
||||
|
||||
def test_update_realm_delete_own_message_policy(self) -> None:
|
||||
"""Tests updating the realm property 'delete_own_message_policy'."""
|
||||
self.set_up_db("delete_own_message_policy", Realm.POLICY_EVERYONE)
|
||||
|
|
|
@ -146,6 +146,11 @@ def update_realm(
|
|||
json_validator=check_bool, default=None
|
||||
),
|
||||
enable_read_receipts: Optional[bool] = REQ(json_validator=check_bool, default=None),
|
||||
move_messages_within_stream_limit_seconds_raw: Optional[Union[int, str]] = REQ(
|
||||
"move_messages_within_stream_limit_seconds",
|
||||
json_validator=check_string_or_int,
|
||||
default=None,
|
||||
),
|
||||
) -> HttpResponse:
|
||||
realm = user_profile.realm
|
||||
|
||||
|
@ -225,6 +230,23 @@ def update_realm(
|
|||
if setting_value_changed:
|
||||
data["message_content_edit_limit_seconds"] = message_content_edit_limit_seconds
|
||||
|
||||
move_messages_within_stream_limit_seconds: Optional[int] = None
|
||||
if move_messages_within_stream_limit_seconds_raw is not None:
|
||||
(
|
||||
move_messages_within_stream_limit_seconds,
|
||||
setting_value_changed,
|
||||
) = parse_and_set_setting_value_if_required(
|
||||
realm,
|
||||
"move_messages_within_stream_limit_seconds",
|
||||
move_messages_within_stream_limit_seconds_raw,
|
||||
acting_user=user_profile,
|
||||
)
|
||||
|
||||
if setting_value_changed:
|
||||
data[
|
||||
"move_messages_within_stream_limit_seconds"
|
||||
] = move_messages_within_stream_limit_seconds
|
||||
|
||||
# The user of `locals()` here is a bit of a code smell, but it's
|
||||
# restricted to the elements present in realm.property_types.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue