mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
message_edit: Use move_messages_between_streams_limit_seconds in webapp.
This commit adds code to check time limit as per recently added move_messages_between_streams_limit_seconds setting when moving messages between streams in webapp. There is no time limit for admins and moderators. We add a new function "is_stream_editable" (similar to already existing is_topic_editable function) to check whether user is allowed to move message between streams.
This commit is contained in:
@@ -179,16 +179,41 @@ export function get_deletability(message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function can_move_message(message) {
|
||||
if (!message.is_stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
export function is_stream_editable(message, edit_limit_seconds_buffer = 0) {
|
||||
if (!is_message_editable_ignoring_permissions(message)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return is_topic_editable(message) || settings_data.user_can_move_messages_between_streams();
|
||||
if (message.type !== "stream") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!settings_data.user_can_move_messages_between_streams()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Organization admins and moderators can edit stream indefinitely,
|
||||
// irrespective of the stream editing deadline, if
|
||||
// move_messages_between_streams_policy allows them to do so.
|
||||
if (page_params.is_admin || page_params.is_moderator) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (page_params.realm_move_messages_between_streams_limit_seconds === null) {
|
||||
// This means no time limit for editing streams.
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
page_params.realm_move_messages_between_streams_limit_seconds +
|
||||
edit_limit_seconds_buffer +
|
||||
(message.timestamp - Date.now() / 1000) >
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
export function can_move_message(message) {
|
||||
return is_topic_editable(message) || is_stream_editable(message);
|
||||
}
|
||||
|
||||
export function stream_and_topic_exist_in_edit_history(message, stream_id, topic) {
|
||||
|
||||
Reference in New Issue
Block a user