message_edit: Use move_messages_within_stream_limit_seconds in webapp.

We now use realm_move_messages_within_stream_limit_seconds setting in
webapp to check topic edit permission replacing the 3-day limit.
As was the case previously, there is no limit for admins and
moderators.
This commit is contained in:
Sahil Batra
2022-10-11 23:05:46 +05:30
committed by Tim Abbott
parent 2c4e076fef
commit d514f2455f
2 changed files with 8 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ const {mock_esm, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test"); const {run_test} = require("../zjsunit/test");
const {page_params} = require("../zjsunit/zpage_params"); const {page_params} = require("../zjsunit/zpage_params");
page_params.realm_community_topic_editing_limit_seconds = 259200; page_params.realm_move_messages_within_stream_limit_seconds = 259200;
const message_edit = zrequire("message_edit"); const message_edit = zrequire("message_edit");
@@ -118,7 +118,7 @@ run_test("is_topic_editable", ({override}) => {
override(settings_data, "user_can_move_messages_to_another_topic", () => false); override(settings_data, "user_can_move_messages_to_another_topic", () => false);
assert.equal(message_edit.is_topic_editable(message), false); assert.equal(message_edit.is_topic_editable(message), false);
page_params.realm_community_topic_editing_limit_seconds = 259200; page_params.realm_move_messages_within_stream_limit_seconds = 259200;
message.timestamp = current_timestamp - 60; message.timestamp = current_timestamp - 60;
override(settings_data, "user_can_move_messages_to_another_topic", () => true); override(settings_data, "user_can_move_messages_to_another_topic", () => true);

View File

@@ -68,9 +68,14 @@ export function is_topic_editable(message, edit_limit_seconds_buffer = 0) {
return true; return true;
} }
if (page_params.realm_move_messages_within_stream_limit_seconds === null) {
// This means no time limit for editing topics.
return true;
}
// If you're using community topic editing, there's a deadline. // If you're using community topic editing, there's a deadline.
return ( return (
page_params.realm_community_topic_editing_limit_seconds + page_params.realm_move_messages_within_stream_limit_seconds +
edit_limit_seconds_buffer + edit_limit_seconds_buffer +
(message.timestamp - Date.now() / 1000) > (message.timestamp - Date.now() / 1000) >
0 0