Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

gifs: Rename `giphy_rating` to `gif_rating_policy`.

apoorvapendsec7ad545f3c65
diff --git a/api_docs/unmerged.d/ZF-dd836d.md b/api_docs/unmerged.d/ZF-dd836d.md
new file mode 100644
index 00000000000..e60cc5937db
--- /dev/null
+++ b/api_docs/unmerged.d/ZF-dd836d.md
@@ -0,0 +1,6 @@
+* [`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/web/src/gif_state.ts b/web/src/gif_state.ts
index dd1a8217278..624163c1208 100644
--- a/web/src/gif_state.ts
+++ b/web/src/gif_state.ts
@@ -8,36 +8,37 @@ type GifRating = "pg" | "pg-13" | "r" | "g";
export function is_tenor_enabled(): boolean {
return (
realm.tenor_api_key !== "" &&
- realm.realm_giphy_rating !== realm.gif_rating_options.disabled.id
+ realm.realm_gif_rating_policy !== realm.gif_rating_options.disabled.id
);
}
export function is_giphy_enabled(): boolean {
return (
realm.giphy_api_key !== "" &&
- realm.realm_giphy_rating !== realm.gif_rating_options.disabled.id
+ realm.realm_gif_rating_policy !== realm.gif_rating_options.disabled.id
);
}
export function get_rating(): GifRating {
const options = realm.gif_rating_options;
for (const rating of ["pg", "g", "pg-13", "r"] as const) {
- if (options[rating]?.id === realm.realm_giphy_rating) {
+ if (options[rating]?.id === realm.realm_gif_rating_policy) {
return rating;
}
}
// The below should never run unless a server bug allowed a
- // `gif_rating` value not present in `gif_rating_options`.
- blueslip.error("Invalid gif_rating value: " + realm.realm_giphy_rating);
+ // `gif_rating_policy` value not present in `gif_rating_options`.
+ blueslip.error("Invalid gif_rating value: " + realm.realm_gif_rating_policy);
return "g";
}
-export function update_gif_rating(): void {
- // Updating the GIF ratings would only result in us showing/hiding
- // the currently set GIF icon.
+export function update_gif_rating_policy(): void {
+ // Updating the GIF rating policy would only result in us showing/hiding
+ // 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_giphy_rating === realm.gif_rating_options.disabled.id) {
+ if (realm.realm_gif_rating_policy === realm.gif_rating_options.disabled.id) {
$(".zulip-icon-gif").hide();
} else {
$(".zulip-icon-gif").show();
diff --git a/web/src/server_events_dispatch.js b/web/src/server_events_dispatch.js
index fc934b424b1..3a54bdb8a59 100644
--- a/web/src/server_events_dispatch.js
+++ b/web/src/server_events_dispatch.js
@@ -334,7 +334,7 @@ export function dispatch_normal_event(event) {
emails_restricted_to_domains: noop,
video_chat_provider: compose_call_ui.update_audio_and_video_chat_button_display,
jitsi_server_url: compose_call_ui.update_audio_and_video_chat_button_display,
- giphy_rating: gif_state.update_gif_rating,
+ gif_rating_policy: gif_state.update_gif_rating_policy,
waiting_period_threshold: noop,
want_advertise_in_communities_directory: noop,
welcome_message_custom_text: noop,
diff --git a/web/src/settings_org.ts b/web/src/settings_org.ts
index d82ec94628f..d91960f8c1c 100644
--- a/web/src/settings_org.ts
+++ b/web/src/settings_org.ts
@@ -240,9 +240,9 @@ function set_video_chat_provider_dropdown(): void {
set_jitsi_server_url_dropdown();
}
-function set_gif_rating_dropdown(): void {
- const rating_id = realm.realm_giphy_rating;
- $("#id_realm_giphy_rating").val(rating_id);
+function set_gif_rating_policy_dropdown(): void {
+ const rating_id = realm.realm_gif_rating_policy;
+ $("#id_realm_gif_rating_policy").val(rating_id);
}
function update_message_edit_sub_settings(is_checked: boolean): void {
@@ -1535,7 +1535,7 @@ export function build_page(): void {
set_realm_waiting_period_setting();
set_video_chat_provider_dropdown();
- set_gif_rating_dropdown();
+ set_gif_rating_policy_dropdown();
set_msg_edit_limit_dropdown();
set_msg_move_limit_setting("realm_move_messages_within_stream_limit_seconds");
set_msg_move_limit_setting("realm_move_messages_between_streams_limit_seconds");
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index d0ed11ee855..836c34bb191 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -512,7 +512,7 @@ export const realm_schema = z.object({
realm_enable_guest_user_indicator: z.boolean(),
realm_enable_read_receipts: z.boolean(),
realm_enable_spectator_access: z.boolean(),
- realm_giphy_rating: z.number(),
+ realm_gif_rating_policy: z.number(),
realm_icon_source: z.string(),
realm_icon_url: z.string(),
realm_incoming_webhook_bots: z.array(
diff --git a/web/templates/settings/organization_settings_admin.hbs b/web/templates/settings/organization_settings_admin.hbs
index 6db7c11d479..8611c37deeb 100644
--- a/web/templates/settings/organization_settings_admin.hbs
+++ b/web/templates/settings/organization_settings_admin.hbs
@@ -169,11 +169,11 @@
</div>
</div>
<div class="input-group">
- <label for="id_realm_giphy_rating" class="settings-field-label">
+ <label for="id_realm_gif_rating_policy" class="settings-field-label">
{{t 'GIF integration' }}
{{> ../help_link_widget link=gif_help_link }}
</label>
- <select name="realm_giphy_rating" class ="setting-widget prop-element settings_select bootstrap-focus-style" id="id_realm_giphy_rating" data-setting-widget-type="number" {{#if gif_api_key_empty}}disabled{{/if}}>
+ <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}}
<option value='{{this.id}}'>{{this.name}}</option>
{{/each}}
diff --git a/web/tests/lib/example_realm.cjs b/web/tests/lib/example_realm.cjs
index 769134d7b27..71af4aa273d 100644
--- a/web/tests/lib/example_realm.cjs
+++ b/web/tests/lib/example_realm.cjs
@@ -85,7 +85,7 @@ exports.make_realm = (opts = {}) => {
realm_enable_guest_user_indicator: false,
realm_enable_read_receipts: false,
realm_enable_spectator_access: false,
- realm_giphy_rating: 0,
+ realm_gif_rating_policy: 0,
realm_icon_source: "",
realm_icon_url: "",
realm_incoming_webhook_bots: [],
diff --git a/zerver/migrations/0773_rename_giphy_rating_realm_gif_rating_policy.py b/zerver/migrations/0773_rename_giphy_rating_realm_gif_rating_policy.py
new file mode 100644
index 00000000000..25f1857ca37
--- /dev/null
+++ b/zerver/migrations/0773_rename_giphy_rating_realm_gif_rating_policy.py
@@ -0,0 +1,17 @@
+# Generated by Django 5.2.9 on 2026-01-13 11:07
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("zerver", "0772_clean_up_imageattachments"),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name="realm",
+ old_name="giphy_rating",
+ new_name="gif_rating_policy",
+ ),
+ ]
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 4ce6126b925..adb0ddc43e7 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -692,9 +692,8 @@ class Realm(models.Model):
},
}
- # maximum rating of the GIFs that will be retrieved.
- # This is now used as a common rating for both Tenor and GIPHY.
- giphy_rating = models.PositiveSmallIntegerField(default=GIF_RATING_OPTIONS["g"]["id"])
+ # Rating policy of the GIFs that will be retrieved.
+ gif_rating_policy = models.PositiveSmallIntegerField(default=GIF_RATING_OPTIONS["g"]["id"])
default_code_block_language = models.TextField(default="")
@@ -724,7 +723,7 @@ class Realm(models.Model):
enable_guest_user_indicator=bool,
enable_read_receipts=bool,
enable_spectator_access=bool,
- giphy_rating=int,
+ gif_rating_policy=int,
inline_image_preview=bool,
inline_url_embed_preview=bool,
invite_required=bool,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 2b39f8a42ce..00e781d889f 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -5085,14 +5085,17 @@ paths:
[server-settings]: https://zulip.readthedocs.io/en/stable/production/settings.html
**Changes**: New in Zulip 5.0 (feature level 109).
- giphy_rating:
+ gif_rating_policy:
type: integer
description: |
Maximum rating of the GIFs that will be retrieved by the
GIPHY and Tenor integrations in this organization.
- **Changes**: In Zulip 12.0 (feature level 442), is now used for
- both the Tenor and GIPHY integrations.
+ **Changes**: Before Zulip 12.0 (feature level ZF-dd836d),
+ this was called `giphy_rating`.
+
+ Before Zulip 12.0 (feature level 442), this was only used
+ for the Giphy integration.
New in Zulip 4.0 (feature level 55).
icon_source:
@@ -19133,7 +19136,7 @@ paths:
**Changes**: New in Zulip 8.0 (feature level 212). Previously, this was only
available as a server-level configuration, which was available via the
`jitsi_server_url` field.
- realm_giphy_rating:
+ realm_gif_rating_policy:
type: integer
description: |
Present if `realm` is present in `fetch_event_types`.
@@ -19141,8 +19144,11 @@ paths:
Maximum rating of the GIFs that will be retrieved by the
GIPHY and Tenor integrations in this organization.
- **Changes**: In Zulip 12.0 (feature level 442), is now used for
- both the Tenor and GIPHY integrations.
+ **Changes**: Before Zulip 12.0 (feature level ZF-dd836d), this was called
+ `realm_giphy_rating`.
+
+ **Changes**: Before Zulip 12.0 (feature level 442), this was only used by
+ the Giphy integration.
New in Zulip 4.0 (feature level 55).
realm_waiting_period_threshold:
diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py
index 40e7c91df68..c1cb5c49253 100644
--- a/zerver/tests/test_events.py
+++ b/zerver/tests/test_events.py
@@ -4398,7 +4398,7 @@ class RealmPropertyActionTest(BaseAction):
Realm.VIDEO_CHAT_PROVIDERS["jitsi_meet"]["id"],
],
jitsi_server_url=["https://jitsi1.example.com", "https://jitsi2.example.com", None],
- giphy_rating=[
+ gif_rating_policy=[
Realm.GIF_RATING_OPTIONS["disabled"]["id"],
],
default_code_block_language=["python", "javascript"],
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index c9efb079f25..dbf40c70f93 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -180,7 +180,7 @@ class HomeTest(ZulipTestCase):
"realm_enable_read_receipts",
"realm_enable_spectator_access",
"realm_filters",
- "realm_giphy_rating",
+ "realm_gif_rating_policy",
"realm_icon_source",
"realm_icon_url",
"realm_incoming_webhook_bots",
diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py
index bd5fa232a69..8343a9d02d3 100644
--- a/zerver/tests/test_realm.py
+++ b/zerver/tests/test_realm.py
@@ -1142,7 +1142,7 @@ class RealmTest(ZulipTestCase):
invalid_values = dict(
message_retention_days=10,
video_chat_provider=10,
- giphy_rating=10,
+ gif_rating_policy=10,
waiting_period_threshold=-10,
digest_weekday=10,
message_content_delete_limit_seconds=-10,
@@ -2209,7 +2209,7 @@ class RealmAPITest(ZulipTestCase):
Realm.VIDEO_CHAT_PROVIDERS["disabled"]["id"],
],
jitsi_server_url=["https://example.jit.si"],
- giphy_rating=[
+ gif_rating_policy=[
Realm.GIF_RATING_OPTIONS["g"]["id"],
Realm.GIF_RATING_OPTIONS["r"]["id"],
],
diff --git a/zerver/views/realm.py b/zerver/views/realm.py
index 5e0094234d2..c0903d3ba52 100644
--- a/zerver/views/realm.py
+++ b/zerver/views/realm.py
@@ -139,7 +139,7 @@ def update_realm(
enable_guest_user_indicator: Json[bool] | None = None,
enable_read_receipts: Json[bool] | None = None,
enable_spectator_access: Json[bool] | None = None,
- giphy_rating: Json[int] | None = None,
+ gif_rating_policy: Json[int] | None = None,
inline_image_preview: Json[bool] | None = None,
inline_url_embed_preview: Json[bool] | None = None,
invite_required: Json[bool] | None = None,
@@ -242,11 +242,13 @@ def update_realm(
video_chat_provider=video_chat_provider
)
)
- if giphy_rating is not None and giphy_rating not in {
+ if gif_rating_policy is not None and gif_rating_policy not in {
p["id"] for p in Realm.GIF_RATING_OPTIONS.values()
}:
raise JsonableError(
- _("Invalid giphy_rating {giphy_rating}").format(giphy_rating=giphy_rating)
+ _("Invalid gif_rating_policy {gif_rating_policy}").format(
+ gif_rating_policy=gif_rating_policy
+ )
)
message_retention_days: int | None = None