Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
gifs: Rename `gif_rating_options` to `gif_rating_policy_options`.
apoorvapendsea288ed186389
diff --git a/api_docs/changelog.md b/api_docs/changelog.mdindex fa0aa9a164a..73b6747822b 100644--- a/api_docs/changelog.md+++ b/api_docs/changelog.md@@ -20,6 +20,17 @@ format used by the Zulip server that they are interacting with.## Changes in Zulip 12.0+**Feature level 453**++* [`POST /register`](/api/register-queue): `gif_rating_options`+ was renamed to `gif_rating_policy_options`.+* [`POST /register`](/api/register-queue): `realm_giphy_rating` was+ renamed to `realm_gif_rating_policy` to reflect that it's shared+ between all GIF picker integrations.+* [`GET /events`](/api/get-events), `PATCH /realm`: `giphy_rating`+ was renamed to `gif_rating_policy` to reflect that it's shared+ between all GIF picker integrations.+**Feature level 452*** [`GET /events`](/api/get-events): Prior to Zulip 12.0 (feature level 452)diff --git a/api_docs/unmerged.d/ZF-dd836d.md b/api_docs/unmerged.d/ZF-dd836d.mddeleted file mode 100644index e60cc5937db..00000000000--- a/api_docs/unmerged.d/ZF-dd836d.md+++ /dev/null@@ -1,6 +0,0 @@-* [`POST /register`](/api/register-queue): `realm_giphy_rating` was- renamed to `realm_gif_rating_policy` to reflect that it's shared- between all GIF picker integrations.-* [`GET /events`](/api/get-events), `PATCH /realm`: `giphy_rating`- was renamed to `gif_rating_policy` to reflect that it's shared- between all GIF picker integrations.diff --git a/version.py b/version.pyindex 773dd6cb4c4..fed5865d40a 100644--- a/version.py+++ b/version.py@@ -35,7 +35,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"# new level means in api_docs/changelog.md, as well as "**Changes**"# entries in the endpoint's documentation in `zulip.yaml`.-API_FEATURE_LEVEL = 452+API_FEATURE_LEVEL = 453# 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. Bumpdiff --git a/web/src/admin.ts b/web/src/admin.tsindex 1bb4164117e..f986f39b5f8 100644--- a/web/src/admin.ts+++ b/web/src/admin.ts@@ -151,7 +151,7 @@ export function build_page(): void {realm_org_type: realm.realm_org_type,realm_available_video_chat_providers: realm.realm_available_video_chat_providers,server_jitsi_server_url: realm.server_jitsi_server_url,- gif_rating_options: realm.gif_rating_options,+ gif_rating_policy_options: realm.gif_rating_policy_options,gif_api_key_empty: realm.giphy_api_key === "" && realm.tenor_api_key === "",realm_description_text: realm.realm_description,realm_description_html: postprocess_content(page_params.realm_rendered_description),diff --git a/web/src/gif_state.ts b/web/src/gif_state.tsindex 624163c1208..095913ce37f 100644--- a/web/src/gif_state.ts+++ b/web/src/gif_state.ts@@ -8,19 +8,19 @@ type GifRating = "pg" | "pg-13" | "r" | "g";export function is_tenor_enabled(): boolean {return (realm.tenor_api_key !== "" &&- realm.realm_gif_rating_policy !== realm.gif_rating_options.disabled.id+ realm.realm_gif_rating_policy !== realm.gif_rating_policy_options.disabled.id);}export function is_giphy_enabled(): boolean {return (realm.giphy_api_key !== "" &&- realm.realm_gif_rating_policy !== realm.gif_rating_options.disabled.id+ realm.realm_gif_rating_policy !== realm.gif_rating_policy_options.disabled.id);}export function get_rating(): GifRating {- const options = realm.gif_rating_options;+ const options = realm.gif_rating_policy_options;for (const rating of ["pg", "g", "pg-13", "r"] as const) {if (options[rating]?.id === realm.realm_gif_rating_policy) {return rating;@@ -28,7 +28,7 @@ export function get_rating(): GifRating {}// The below should never run unless a server bug allowed a- // `gif_rating_policy` value not present in `gif_rating_options`.+ // `gif_rating_policy` value not present in `gif_rating_policy_options`.blueslip.error("Invalid gif_rating value: " + realm.realm_gif_rating_policy);return "g";}@@ -38,7 +38,7 @@ export function update_gif_rating_policy(): void {// the currently set GIF icon depending on whether the policy is configured// to `disabled`.// It won't change the GIF provider without a server restart as of now.- if (realm.realm_gif_rating_policy === realm.gif_rating_options.disabled.id) {+ if (realm.realm_gif_rating_policy === realm.gif_rating_policy_options.disabled.id) {$(".zulip-icon-gif").hide();} else {$(".zulip-icon-gif").show();diff --git a/web/src/state_data.ts b/web/src/state_data.tsindex 836c34bb191..6d761cf31a6 100644--- a/web/src/state_data.ts+++ b/web/src/state_data.ts@@ -420,7 +420,7 @@ export const realm_schema = z.object({custom_profile_field_types: custom_profile_field_types_schema,demo_organization_scheduled_deletion_date: z.optional(z.number()),giphy_api_key: z.string(),- gif_rating_options: z.intersection(+ gif_rating_policy_options: z.intersection(z.record(z.string(), z.object({id: z.number(), name: z.string()})),z.object({disabled: z.object({id: z.number(), name: z.string()})}),),diff --git a/web/templates/settings/organization_settings_admin.hbs b/web/templates/settings/organization_settings_admin.hbsindex 8611c37deeb..b70b877830b 100644--- a/web/templates/settings/organization_settings_admin.hbs+++ b/web/templates/settings/organization_settings_admin.hbs@@ -174,7 +174,7 @@{{> ../help_link_widget link=gif_help_link }}</label><select name="realm_gif_rating_policy" class ="setting-widget prop-element settings_select bootstrap-focus-style" id="id_realm_gif_rating_policy" data-setting-widget-type="number" {{#if gif_api_key_empty}}disabled{{/if}}>- {{#each gif_rating_options}}+ {{#each gif_rating_policy_options}}<option value='{{this.id}}'>{{this.name}}</option>{{/each}}</select>diff --git a/web/tests/lib/example_realm.cjs b/web/tests/lib/example_realm.cjsindex 71af4aa273d..f54a312d8c0 100644--- a/web/tests/lib/example_realm.cjs+++ b/web/tests/lib/example_realm.cjs@@ -7,7 +7,7 @@ exports.make_realm = (opts = {}) => {custom_profile_fields: [],custom_profile_field_types: [],giphy_api_key: "giphy-api-key",- gif_rating_options: {disabled: {id: 0, name: ""}},+ gif_rating_policy_options: {disabled: {id: 0, name: ""}},max_avatar_file_size_mib: 0,max_channel_folder_description_length: 0,max_channel_folder_name_length: 0,diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex 7a937faf84d..47e8af9a90a 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -400,7 +400,7 @@ def fetch_initial_state_data(## Other settings, which are just server-level settings or data# about the version of Zulip, can be named without prefixes,- # e.g. gif_rating_options or development_environment.+ # e.g. gif_rating_policy_options or development_environment.# If we no longer have a translation for the organization's language,# correct the organization to have one; this block is a workaround for@@ -546,7 +546,7 @@ def fetch_initial_state_data(state["server_avatar_changes_disabled"] = settings.AVATAR_CHANGES_DISABLEDstate["server_name_changes_disabled"] = settings.NAME_CHANGES_DISABLEDstate["server_web_public_streams_enabled"] = settings.WEB_PUBLIC_STREAMS_ENABLED- state["gif_rating_options"] = realm.get_gif_rating_options()+ state["gif_rating_policy_options"] = realm.get_gif_rating_policy_options()state["server_emoji_data_url"] = emoji.data_url()diff --git a/zerver/models/realms.py b/zerver/models/realms.pyindex adb0ddc43e7..2200771b814 100644--- a/zerver/models/realms.py+++ b/zerver/models/realms.py@@ -665,8 +665,8 @@ class Realm(models.Model):JITSI_SERVER_SPECIAL_VALUES_MAP = {"default": None}jitsi_server_url = models.URLField(null=True, default=None)- # Please access this via get_gif_rating_options.- GIF_RATING_OPTIONS = {+ # Please access this via get_gif_rating_policy_options.+ GIF_RATING_POLICY_OPTIONS = {"disabled": {"name": gettext_lazy("GIF integration disabled"),"id": 0,@@ -693,7 +693,9 @@ class Realm(models.Model):}# Rating policy of the GIFs that will be retrieved.- gif_rating_policy = models.PositiveSmallIntegerField(default=GIF_RATING_OPTIONS["g"]["id"])+ gif_rating_policy = models.PositiveSmallIntegerField(+ default=GIF_RATING_POLICY_OPTIONS["g"]["id"]+ )default_code_block_language = models.TextField(default="")@@ -924,12 +926,12 @@ class Realm(models.Model):def __str__(self) -> str:return f"{self.string_id} {self.id}"- def get_gif_rating_options(self) -> dict[str, dict[str, object]]:- """Wrapper function for GIF_RATING_OPTIONS that ensures evaluation+ def get_gif_rating_policy_options(self) -> dict[str, dict[str, object]]:+ """Wrapper function for GIF_RATING_POLICY_OPTIONS that ensures evaluationof the lazily evaluated `name` field without modifying the original."""return {rating_type: {"name": str(rating["name"]), "id": rating["id"]}- for rating_type, rating in self.GIF_RATING_OPTIONS.items()+ for rating_type, rating in self.GIF_RATING_POLICY_OPTIONS.items()}def authentication_methods_dict(self) -> dict[str, bool]:diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yamlindex 00e781d889f..1ca795f5207 100644--- a/zerver/openapi/zulip.yaml+++ b/zerver/openapi/zulip.yaml@@ -5091,7 +5091,7 @@ paths:Maximum rating of the GIFs that will be retrieved by theGIPHY and Tenor integrations in this organization.- **Changes**: Before Zulip 12.0 (feature level ZF-dd836d),+ **Changes**: Before Zulip 12.0 (feature level 453),this was called `giphy_rating`.Before Zulip 12.0 (feature level 442), this was only used@@ -19144,7 +19144,7 @@ paths:Maximum rating of the GIFs that will be retrieved by theGIPHY and Tenor integrations in this organization.- **Changes**: Before Zulip 12.0 (feature level ZF-dd836d), this was called+ **Changes**: Before Zulip 12.0 (feature level 453), this was called`realm_giphy_rating`.**Changes**: Before Zulip 12.0 (feature level 442), this was only used by@@ -19744,7 +19744,7 @@ paths:This Zulip server's configured minimum `zxcvbn` minimum guesses.Necessary for password change UI to show whether the passwordwill be accepted.- gif_rating_options:+ gif_rating_policy_options:type: objectdescription: |Present if `realm` is present in `fetch_event_types`.@@ -19756,9 +19756,12 @@ paths:Useful for administrative settings UI that allows changing theallowed rating of GIFs.- **Changes**: New in Zulip 12.0 (feature level 442). Previously,- this was called `giphy_rating_options` and only supported the- original GIPHY gif picker integration.+ **Changes**: Before Zulip 12.0 (feature level 453), this was+ called `gif_rating_options`.++ **Changes**: Before Zulip 12.0 (feature level 442), this was called+ `giphy_rating_options` and only supported the original GIPHY gif picker+ integration.`giphy_rating_options` was new in Zulip 4.0 (feature level 55).additionalProperties:diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.pyindex c1cb5c49253..0cf7b784b90 100644--- a/zerver/tests/test_events.py+++ b/zerver/tests/test_events.py@@ -4399,7 +4399,7 @@ class RealmPropertyActionTest(BaseAction):],jitsi_server_url=["https://jitsi1.example.com", "https://jitsi2.example.com", None],gif_rating_policy=[- Realm.GIF_RATING_OPTIONS["disabled"]["id"],+ Realm.GIF_RATING_POLICY_OPTIONS["disabled"]["id"],],default_code_block_language=["python", "javascript"],message_content_delete_limit_seconds=[1000, 1100, 1200, None],diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.pyindex dbf40c70f93..188e9e6540b 100644--- a/zerver/tests/test_home.py+++ b/zerver/tests/test_home.py@@ -90,7 +90,7 @@ class HomeTest(ZulipTestCase):"full_name","giphy_api_key","tenor_api_key",- "gif_rating_options",+ "gif_rating_policy_options","has_zoom_token","is_admin","is_guest",diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.pyindex 8343a9d02d3..4a4114e2241 100644--- a/zerver/tests/test_realm.py+++ b/zerver/tests/test_realm.py@@ -2210,8 +2210,8 @@ class RealmAPITest(ZulipTestCase):],jitsi_server_url=["https://example.jit.si"],gif_rating_policy=[- Realm.GIF_RATING_OPTIONS["g"]["id"],- Realm.GIF_RATING_OPTIONS["r"]["id"],+ Realm.GIF_RATING_POLICY_OPTIONS["g"]["id"],+ Realm.GIF_RATING_POLICY_OPTIONS["r"]["id"],],message_content_delete_limit_seconds=[1000, 1100, 1200],message_content_edit_limit_seconds=[1000, 1100, 1200],diff --git a/zerver/views/realm.py b/zerver/views/realm.pyindex c0903d3ba52..342b9b51648 100644--- a/zerver/views/realm.py+++ b/zerver/views/realm.py@@ -243,7 +243,7 @@ def update_realm())if gif_rating_policy is not None and gif_rating_policy not in {- p["id"] for p in Realm.GIF_RATING_OPTIONS.values()+ p["id"] for p in Realm.GIF_RATING_POLICY_OPTIONS.values()}:raise JsonableError(_("Invalid gif_rating_policy {gif_rating_policy}").format(