diff --git a/frontend_tests/node_tests/message_edit.js b/frontend_tests/node_tests/message_edit.js index 30fda7b6e8..83d975b071 100644 --- a/frontend_tests/node_tests/message_edit.js +++ b/frontend_tests/node_tests/message_edit.js @@ -1,5 +1,7 @@ set_global('document', null); -set_global('page_params', {}); +set_global('page_params', { + realm_community_topic_editing_limit_seconds: 86400, +}); global.stub_out_jquery(); @@ -75,6 +77,7 @@ run_test('get_editability', () => { realm_allow_community_topic_editing: true, realm_allow_message_editing: true, realm_message_content_edit_limit_seconds: 0, + realm_community_topic_editing_limit_seconds: 86400, is_admin: false, }; message.timestamp = current_timestamp - 60; diff --git a/static/js/message_edit.js b/static/js/message_edit.js index 9dbe84ebcf..fca3be47f5 100644 --- a/static/js/message_edit.js +++ b/static/js/message_edit.js @@ -47,9 +47,9 @@ function is_topic_editable(message, edit_limit_seconds_buffer) { } // If you're using community topic editing, there's a deadline. - // TODO: Change hardcoded value (24 hrs) to be realm setting. Currently, it is - // DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS - return 86400 + edit_limit_seconds_buffer + now.diffSeconds(message.timestamp * 1000) > 0; + return page_params.realm_community_topic_editing_limit_seconds + + edit_limit_seconds_buffer + + now.diffSeconds(message.timestamp * 1000) > 0; } function get_editability(message, edit_limit_seconds_buffer) { diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index b440716018..2205027a82 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -10,6 +10,13 @@ below features are supported. ## Changes in Zulip 2.2 +**Feature level 11** + +* [`POST /register`](/api/register-queue): Added + `realm_community_topic_editing_limit_seconds` to the response, the + time limit before community topic editing is forbidden. A `null` + value means no limit. + **Feature level 10** * [`GET users/me`](/api/get-profile): Added `avatar_version`, `is_guest`, diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 46bc0ab40d..ef26aa6893 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -147,6 +147,8 @@ def fetch_initial_state_data(user_profile: UserProfile, state['realm_allow_message_deleting'] = realm.allow_message_deleting state['realm_message_content_edit_limit_seconds'] = realm.message_content_edit_limit_seconds state['realm_message_content_delete_limit_seconds'] = realm.message_content_delete_limit_seconds + state['realm_community_topic_editing_limit_seconds'] = \ + Realm.DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS state['realm_icon_url'] = realm_icon_url(realm) state['realm_icon_source'] = realm.icon_source state['max_icon_file_size'] = settings.MAX_ICON_FILE_SIZE diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index 56e0f441ed..186155e7f0 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -134,6 +134,7 @@ class HomeTest(ZulipTestCase): "realm_bot_creation_policy", "realm_bot_domain", "realm_bots", + "realm_community_topic_editing_limit_seconds", "realm_create_stream_policy", "realm_default_code_block_language", "realm_default_external_accounts",