message_edit: Use move_messages_between_streams_limit_seconds setting.

This commit adds time restriction on moving messages between streams
using the move_messages_between_streams_limit_seconds setting in the
backend. There is no time limit for admins and moderators.
This commit is contained in:
Sahil Batra
2022-12-22 12:55:29 +05:30
committed by Tim Abbott
parent d514f2455f
commit 891f83601d
5 changed files with 109 additions and 6 deletions

View File

@@ -1019,6 +1019,19 @@ def check_update_message(
new_stream = access_stream_by_id(user_profile, stream_id, require_active=True)[0]
check_stream_access_based_on_stream_post_policy(user_profile, new_stream)
if (
user_profile.realm.move_messages_between_streams_limit_seconds is not None
and not user_profile.is_realm_admin
and not user_profile.is_moderator
):
deadline_seconds = (
user_profile.realm.move_messages_between_streams_limit_seconds + edit_limit_buffer
)
if (timezone_now() - message.date_sent) > datetime.timedelta(seconds=deadline_seconds):
raise JsonableError(
_("The time limit for editing this message's stream has passed")
)
number_changed = do_update_message(
user_profile,
message,