From 5459a92e4a87f647d19b910d46ac3d68730dd506 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Mon, 2 Aug 2021 22:13:08 +0530 Subject: [PATCH] setting: Use "unlimited" instead of "forever" for retention setting. This commit updates both the stream-level and realm-level message retention setting to use 'unlimited' instead of 'forever' to set message retention setting to "retain messages forever". --- static/js/settings_org.js | 2 +- static/js/stream_edit.js | 4 ++-- static/templates/stream_settings/stream_types.hbs | 2 +- templates/zerver/api/changelog.md | 7 +++++++ version.py | 2 +- zerver/models.py | 4 ++-- zerver/openapi/zulip.yaml | 13 ++++++++++--- zerver/tests/test_realm.py | 2 +- zerver/tests/test_subs.py | 2 +- 9 files changed, 26 insertions(+), 12 deletions(-) diff --git a/static/js/settings_org.js b/static/js/settings_org.js index 52a6e34444..e7f34a4b1a 100644 --- a/static/js/settings_org.js +++ b/static/js/settings_org.js @@ -810,7 +810,7 @@ export function build_page() { "#id_realm_message_retention_setting", ).val(); if (message_retention_setting_value === "retain_forever") { - data.message_retention_days = JSON.stringify("forever"); + data.message_retention_days = JSON.stringify("unlimited"); } else { data.message_retention_days = JSON.stringify( get_input_element_value($("#id_realm_message_retention_days")), diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js index 7e114a5c3f..6e1cdefe83 100644 --- a/static/js/stream_edit.js +++ b/static/js/stream_edit.js @@ -151,7 +151,7 @@ function set_stream_message_retention_setting_dropdown(stream) { if (stream.message_retention_days === null) { value = "realm_default"; } else if (stream.message_retention_days === settings_config.retain_message_forever) { - value = "forever"; + value = "unlimited"; } $(".stream_message_retention_setting").val(value); @@ -637,7 +637,7 @@ function get_message_retention_days_from_sub(sub) { return "realm_default"; } if (sub.message_retention_days === -1) { - return "forever"; + return "unlimited"; } return sub.message_retention_days; } diff --git a/static/templates/stream_settings/stream_types.hbs b/static/templates/stream_settings/stream_types.hbs index 94d0b62fe8..3664b84c2d 100644 --- a/static/templates/stream_settings/stream_types.hbs +++ b/static/templates/stream_settings/stream_types.hbs @@ -44,7 +44,7 @@ class="stream_message_retention_setting" class="prop-element" {{#if disable_message_retention_setting}}disabled{{/if}}> - + diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index 6fe7d506f2..6b5d7aaafb 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -11,6 +11,13 @@ below features are supported. ## Changes in Zulip 5.0 +**Feature level 91** + +* `PATCH /realm`, [`PATCH /streams/{stream_id}`](/api/update-stream): + These endpoints now accept `"unlimited"` for `message_retention_days`, + replacing `"forever"` as the way to encode a retention policy where + messages are not automatically deleted. + **Feature level 90** * [`POST /register`](/api/register-queue): The `unread_msgs` section diff --git a/version.py b/version.py index 7ba4ab498c..bbec5cda0c 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3" # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md, as well as # "**Changes**" entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 90 +API_FEATURE_LEVEL = 91 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/models.py b/zerver/models.py index 93d22c97ac..2aa7d95a77 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -404,7 +404,7 @@ class Realm(models.Model): ) MESSAGE_RETENTION_SPECIAL_VALUES_MAP = { - "forever": -1, + "unlimited": -1, } # For old messages being automatically deleted message_retention_days: int = models.IntegerField(null=False, default=-1) @@ -2063,7 +2063,7 @@ class Stream(models.Model): # Value -1 means "disable retention policy for this stream unconditionally". # Non-negative values have the natural meaning of "archive messages older than days". MESSAGE_RETENTION_SPECIAL_VALUES_MAP = { - "forever": -1, + "unlimited": -1, "realm_default": None, } message_retention_days: Optional[int] = models.IntegerField(null=True, default=None) diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 7d3f73b48b..3000ecf6b5 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -10051,8 +10051,11 @@ paths: Present if `realm` is present in `fetch_event_types`. The default [message retention policy](/help/message-retention-policy) - for this organization. Pass `"forever"` to request that messages + for this organization. Pass `"unlimited"` to request that messages by retained forever (the default). + + **Changes**: Prior to Zulip 5.0 (feature level 91), no limit was encoded + by passing `"forever"`. realm_name: type: string description: | @@ -14548,9 +14551,13 @@ components: values are supported: * "realm_default" => Return to the organization-level setting. - * "forever" => Retain messages forever. + * "unlimited" => Retain messages forever. - **Changes**: New in Zulip 3.0 (feature level 17). + **Changes**: Prior to Zulip 5.0 (feature level 91), retaining + messages forever was encoded using `"forever"` instead of + `"unlimited"`. + + New in Zulip 3.0 (feature level 17). schema: oneOf: - type: string diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index 4bda7f1927..e9cda57185 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -644,7 +644,7 @@ class RealmTest(ZulipTestCase): result = self.client_patch("/json/realm", req) self.assert_json_error(result, "Bad value for 'message_retention_days': -1") - req = dict(message_retention_days=orjson.dumps("forever").decode()) + req = dict(message_retention_days=orjson.dumps("unlimited").decode()) result = self.client_patch("/json/realm", req) self.assert_json_success(result) diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index af6ea540b9..7d104008a2 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -1204,7 +1204,7 @@ class StreamAdminTest(ZulipTestCase): with self.tornado_redirected_to_list(events, expected_num_events=1): result = self.client_patch( f"/json/streams/{stream.id}", - {"message_retention_days": orjson.dumps("forever").decode()}, + {"message_retention_days": orjson.dumps("unlimited").decode()}, ) self.assert_json_success(result) event = events[0]["event"]