mirror of https://github.com/zulip/zulip.git
message_edit: Use move_messages_within_stream_limit_seconds setting.
We now use the newly added move_messages_within_stream_limit_seconds setting to check for how long the user can edit the topic replacing the previously used 3-day limit. As it was previously, there is no time limit for admins and moderators.
This commit is contained in:
parent
b919dfd489
commit
2c4e076fef
|
@ -26,6 +26,9 @@ format used by the Zulip server that they are interacting with.
|
||||||
`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),
|
* [`POST /register`](/api/register-queue), [`GET /events`](/api/get-events),
|
||||||
`PATCH /realm`: Added new `move_messages_between_streams_limit_seconds` setting.
|
`PATCH /realm`: Added new `move_messages_between_streams_limit_seconds` setting.
|
||||||
|
* [`PATCH /messages/{message_id}`](/api/update-message): Time limit to edit
|
||||||
|
topics, for users other than administrators and moderators, can now be
|
||||||
|
configured using `move_messages_within_stream_limit_seconds` setting.
|
||||||
|
|
||||||
**Feature level 161**
|
**Feature level 161**
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ from zerver.models import (
|
||||||
Attachment,
|
Attachment,
|
||||||
Message,
|
Message,
|
||||||
Reaction,
|
Reaction,
|
||||||
Realm,
|
|
||||||
Stream,
|
Stream,
|
||||||
UserMessage,
|
UserMessage,
|
||||||
UserProfile,
|
UserProfile,
|
||||||
|
@ -955,11 +954,14 @@ def check_update_message(
|
||||||
# and the time limit for editing topics is passed, raise an error.
|
# and the time limit for editing topics is passed, raise an error.
|
||||||
if (
|
if (
|
||||||
topic_name is not None
|
topic_name is not None
|
||||||
|
and user_profile.realm.move_messages_within_stream_limit_seconds is not None
|
||||||
and not user_profile.is_realm_admin
|
and not user_profile.is_realm_admin
|
||||||
and not user_profile.is_moderator
|
and not user_profile.is_moderator
|
||||||
and not is_no_topic_msg
|
and not is_no_topic_msg
|
||||||
):
|
):
|
||||||
deadline_seconds = Realm.DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS + edit_limit_buffer
|
deadline_seconds = (
|
||||||
|
user_profile.realm.move_messages_within_stream_limit_seconds + edit_limit_buffer
|
||||||
|
)
|
||||||
if (timezone_now() - message.date_sent) > datetime.timedelta(seconds=deadline_seconds):
|
if (timezone_now() - message.date_sent) > datetime.timedelta(seconds=deadline_seconds):
|
||||||
raise JsonableError(_("The time limit for editing this message's topic has passed"))
|
raise JsonableError(_("The time limit for editing this message's topic has passed"))
|
||||||
|
|
||||||
|
|
|
@ -6489,6 +6489,12 @@ paths:
|
||||||
**Note**: See [configuring message editing][config-message-editing]
|
**Note**: See [configuring message editing][config-message-editing]
|
||||||
for detailed documentation on when users are allowed to edit topics.
|
for detailed documentation on when users are allowed to edit topics.
|
||||||
|
|
||||||
|
**Changes**: Before Zulip 7.0 (feature level 162), users who
|
||||||
|
were not administrators or moderators could only edit topics
|
||||||
|
if the target message was sent within the last 3 days. That
|
||||||
|
time limit is now controlled by the
|
||||||
|
`move_messages_within_stream_limit_seconds` setting.
|
||||||
|
|
||||||
**Changes**: Before Zulip 7.0 (feature level 159), editing
|
**Changes**: Before Zulip 7.0 (feature level 159), editing
|
||||||
streams and topics of messages was forbidden if
|
streams and topics of messages was forbidden if
|
||||||
`allow_message_editing` was `false`, regardless of the
|
`allow_message_editing` was `false`, regardless of the
|
||||||
|
|
|
@ -1180,9 +1180,9 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
set_message_editing_params(False, "unlimited", Realm.POLICY_EVERYONE)
|
set_message_editing_params(False, "unlimited", Realm.POLICY_EVERYONE)
|
||||||
do_edit_message_assert_success(id_, "D", "cordelia")
|
do_edit_message_assert_success(id_, "D", "cordelia")
|
||||||
|
|
||||||
# non-admin users cannot edit topics sent > 72 hrs ago including
|
# non-admin users cannot edit topics sent > 1 week ago including
|
||||||
# sender of the message.
|
# sender of the message.
|
||||||
message.date_sent = message.date_sent - datetime.timedelta(seconds=290000)
|
message.date_sent = message.date_sent - datetime.timedelta(seconds=604900)
|
||||||
message.save()
|
message.save()
|
||||||
set_message_editing_params(True, "unlimited", Realm.POLICY_EVERYONE)
|
set_message_editing_params(True, "unlimited", Realm.POLICY_EVERYONE)
|
||||||
do_edit_message_assert_success(id_, "E", "iago")
|
do_edit_message_assert_success(id_, "E", "iago")
|
||||||
|
@ -1194,6 +1194,16 @@ class EditMessageTest(EditMessageTestCase):
|
||||||
id_, "G", "The time limit for editing this message's topic has passed", "hamlet"
|
id_, "G", "The time limit for editing this message's topic has passed", "hamlet"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# set the topic edit limit to two weeks
|
||||||
|
do_set_realm_property(
|
||||||
|
hamlet.realm,
|
||||||
|
"move_messages_within_stream_limit_seconds",
|
||||||
|
604800 * 2,
|
||||||
|
acting_user=None,
|
||||||
|
)
|
||||||
|
do_edit_message_assert_success(id_, "G", "cordelia")
|
||||||
|
do_edit_message_assert_success(id_, "H", "hamlet")
|
||||||
|
|
||||||
# anyone should be able to edit "no topic" indefinitely
|
# anyone should be able to edit "no topic" indefinitely
|
||||||
message.set_topic_name("(no topic)")
|
message.set_topic_name("(no topic)")
|
||||||
message.save()
|
message.save()
|
||||||
|
|
Loading…
Reference in New Issue