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: Introduce KLIPY as a GIF provider.

apoorvapendse5c7adf65d19b
diff --git a/api_docs/changelog.md b/api_docs/changelog.md
index 1a62d8f3b04..0e16cda85fe 100644
--- a/api_docs/changelog.md
+++ b/api_docs/changelog.md
@@ -20,6 +20,11 @@ format used by the Zulip server that they are interacting with.
## Changes in Zulip 12.0
+**Feature level 486**
+
+* [`POST /register`](/api/register-queue): Added new `klipy_api_key`
+ field, which is required to fetch GIFs using the KLIPY API.
+
**Feature level 485**
* [`POST /register`](/api/register-queue): Renamed the `validator` field
diff --git a/docs/production/gif-picker-integrations.md b/docs/production/gif-picker-integrations.md
index 91f2986f25a..d0b2846a4f9 100644
--- a/docs/production/gif-picker-integrations.md
+++ b/docs/production/gif-picker-integrations.md
@@ -5,8 +5,8 @@ GIPHY or Tenor integrations to [add GIFs in your message][help-center-giphy] on
a self-hosted Zulip server.
:::{note}
-If API keys are configured for both integrations, Zulip will prioritize Tenor.
-In this case, the GIF picker will use Tenor instead of GIPHY.
+If API keys are configured for multiple integrations, Zulip will prioritize
+Tenor, followed by KLIPY, and then GIPHY.
:::
## GIPHY
@@ -101,6 +101,48 @@ Zulip server. Your users can now use the integration as described in
[the help center article][help-center-giphy]. (A browser reload may
be required).
+## KLIPY
+
+To enable the KLIPY GIF integration, you will need to create
+a test or production API key from KLIPY.
+
+### Create a KLIPY API key
+
+1. On the KLIPY Developer page, navigate to the [API Keys section](https://partner.klipy.com/api-keys)
+
+1. Select **Add Platform** and enter the details of your Zulip server.
+
+1. In the **Create API Key** modal, enter the relevant details and select **Create**.
+
+1. You will receive a [rate-limited][klipy-api-key-rate-limit] test API key, which
+ may be sufficient for smaller Zulip servers.
+
+1. (_optional_) If the test API key rate limit is too low for your Zulip server,
+ you can click on the **three-dot button** on the right and select **Request Production**.
+ Enter the necessary details and select **Apply**.
+
+1. Store the newly generated API key.
+
+You can then configure your Zulip server to use the KLIPY API
+as follows:
+
+1. In `/etc/zulip/settings.py`, enter your KLIPY API key as
+ `KLIPY_API_KEY = "<Your API key>"`.
+
+ Just like GIPHY API keys, KLIPY API keys are not secrets -- KLIPY expects
+ every browser or other client connecting to your Zulip server will
+ receive a copy -- which is why they are configured in `settings.py` and not
+ `zulip-secrets.conf`.
+
+1. Restart the Zulip server with
+ `/home/zulip/deployments/current/scripts/restart-server`.
+
+Congratulations! You've configured the KLIPY integration for your
+Zulip server. Your users can now use the integration as described in
+[the help center article][help-center-giphy]. (A browser reload may
+be required).
+
[help-center-giphy]: https://zulip.com/help/animated-gifs-from-giphy
[giphy-dashboard]: https://developers.giphy.com/dashboard/
[giphy-beta-api]: https://support.giphy.com/hc/en-us/articles/360035340511
+[klipy-api-key-rate-limit]: https://partner.klipy.com/faqs#4
diff --git a/starlight_help/src/content/docs/animated-gifs.mdx b/starlight_help/src/content/docs/animated-gifs.mdx
index 929838e9ed7..3fcb0b09082 100644
--- a/starlight_help/src/content/docs/animated-gifs.mdx
+++ b/starlight_help/src/content/docs/animated-gifs.mdx
@@ -17,7 +17,8 @@ import GifIcon from "~icons/zulip-icon/gif";
<ZulipNote>
On self-hosted servers, the GIF picker needs to be
[configured][configure-gifs] by a server administrator. You can choose between
- [GIPHY](https://giphy.com) and [Tenor](https://tenor.com/) as your GIF provider.
+ [GIPHY](https://giphy.com), [Tenor](https://tenor.com/) and [KLIPY](https://klipy.com)
+ as your GIF provider.
</ZulipNote>
Zulip makes it easy to find animated GIFs and use them in your messages, if the
@@ -87,7 +88,7 @@ Zulip’s GIF picker uses a third-party service to provide GIFs
([Tenor](https://tenor.com/) for Zulip Cloud). Any text you enter into the GIF
search box will be sent from your browser directly to the corresponding
service’s API. Because these requests are made client-side, the service you are
-querying (Tenor or GIPHY) will be able to see your IP address and may use that
+querying (Tenor, GIPHY or KLIPY) will be able to see your IP address and may use that
data for tracking, similar to if you visited their website and performed the
same search there.
diff --git a/static/images/integrations/bot_avatars/klipy.png b/static/images/integrations/bot_avatars/klipy.png
new file mode 100644
index 00000000000..ede1105b804
Binary files /dev/null and b/static/images/integrations/bot_avatars/klipy.png differ
diff --git a/static/images/integrations/logos/klipy.svg b/static/images/integrations/logos/klipy.svg
new file mode 100644
index 00000000000..f32c99bd2e7
--- /dev/null
+++ b/static/images/integrations/logos/klipy.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" id="Layer_1" x="0" y="0" viewBox="0 0 397.7 137.1"><style>.st1{fill:#ee4523}</style><path d="M217.8 137.1h-21c-2.4 0-4.3-1.9-4.3-4.3V42.9c0-2.4 1.9-4.3 4.3-4.3h21c2.4 0 4.3 1.9 4.3 4.3v89.9c0 2.4-1.9 4.3-4.3 4.3M144.8 106.9v-64c0-2.4-1.9-4.3-4.3-4.3h-21c-2.4 0-4.3 1.9-4.3 4.3v89.9c0 2.4 1.9 4.3 4.3 4.3H182c2.4 0 4.3-1.9 4.3-4.3v-17.3c0-2.4-1.9-4.3-4.3-4.3h-33c-2.3 0-4.2-1.9-4.2-4.3M269.3 38.6h-37c-2.4 0-4.3 1.9-4.3 4.3v89.9c0 2.4 1.9 4.3 4.3 4.3h21c2.4 0 4.3-1.9 4.3-4.3V108c0-.8.7-1.3 1.4-1.1 10.5 3.1 24.3 3.4 36.2-8.4 25.3-25.3 1.4-59.9-25.9-59.9m7.4 43.2c-11.2 7.9-23.6-4.5-15.7-15.7.3-.4.6-.7 1-1 11.2-7.9 23.6 4.5 15.7 15.7-.3.4-.7.7-1 1"/><path d="m396.5 54.2-14.4-14.4c-1.6-1.6-4.2-1.6-5.9 0l-23 23c-.6.6-1.7.6-2.3 0l-23-23c-1.6-1.6-4.2-1.6-5.9 0l-14.4 14.4c-1.6 1.6-1.6 4.2 0 5.9l29.6 29.6c.3.3.5.8.5 1.2V133c0 2.3 1.9 4.1 4.1 4.1h20.4c2.3 0 4.1-1.9 4.1-4.1V90.9c0-.5.2-.9.5-1.2l29.6-29.6c1.7-1.6 1.7-4.3.1-5.9"/><path d="M107.9 133.3 79 88.7c-.5-.8-.5-1.8 0-2.6l27.1-44.6c1-1.7-.2-3.8-2.1-3.8l-17.1 3.9c-13.6 3.1-17.6 11-25.8 22.3-1.6 2.2-2.6 3.7-2.6 3.7-1.2 2.3-4.7 1.4-4.7-1.2V29.7c-10.4 0-15.8 3.8-20 7.3C20.8 47.7 18 61 18 77.9v56.7c0 1.4 1.1 2.5 2.5 2.5h30.9c1.4 0 2.5-1.1 2.5-2.5v-28.3c0-2.5 3.3-3.4 4.6-1.3L69 135.9c.5.8 1.3 1.2 2.1 1.2h34.8c1.9 0 3.1-2.2 2-3.8M46.6 42.7c-1.9 0-3.4-1.5-3.4-3.4s1.5-3.4 3.4-3.4 3.4 1.5 3.4 3.4-1.5 3.4-3.4 3.4" style="fill:#f7dc3c"/><path d="M13.5 62.4c.3.7 2.7-38 40.6-38.3 0 0-30.7-36-42.1-20 0 0-5.6 8.8 5.2 11.6 0 0-17.5 4.6-17.2 16.8.1 3.8 4 6.3 7.5 4.8 2-.9 4.6-2.6 7.9-5.7 0-.1-7.7 15.3-1.9 30.8M57.9 31.2v9.4c0 .7.7 1.1 1.3.7l9-6-9-4.9c-.6-.2-1.3.2-1.3.8" class="st1"/></svg>
\ No newline at end of file
diff --git a/templates/zerver/integrations/klipy.md b/templates/zerver/integrations/klipy.md
new file mode 100644
index 00000000000..2bee48b9589
--- /dev/null
+++ b/templates/zerver/integrations/klipy.md
@@ -0,0 +1,13 @@
+# Zulip KLIPY GIF integration
+
+Send animated GIFs with your message using KLIPY.
+
+Follow [these instructions][configure-klipy] to configure KLIPY on a
+**self-hosted** Zulip server.
+
+### Related documentation
+
+* [Using GIFs in Zulip][help-center-gifs]
+
+[help-center-gifs]: /help/animated-gifs
+[configure-klipy]: https://zulip.readthedocs.io/en/latest/production/gif-picker-integrations.html
diff --git a/tools/lib/capitalization.py b/tools/lib/capitalization.py
index 32a752c5399..b44986a28e4 100644
--- a/tools/lib/capitalization.py
+++ b/tools/lib/capitalization.py
@@ -157,6 +157,8 @@ IGNORED_PHRASES = [
r"GIPHY",
# Used for Tenor attributions
r"Search Tenor",
+ # Used for KLIPY attributions
+ r"Search KLIPY",
# Used in our case studies
r"Technical University of Munich",
r"University of California San Diego",
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index b1b82b1a4d3..a1eafaf8f8d 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -140,6 +140,7 @@ EXEMPT_FILES = make_set(
"web/src/integration_url_modal.ts",
"web/src/invite.ts",
"web/src/invite_stream_picker_pill.ts",
+ "web/src/klipy_network.ts",
"web/src/left_sidebar_navigation_area.ts",
"web/src/left_sidebar_navigation_area_popovers.ts",
"web/src/left_sidebar_tooltips.ts",
diff --git a/version.py b/version.py
index 093c6e36c87..498e9720436 100644
--- a/version.py
+++ b/version.py
@@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
# https://zulip.readthedocs.io/en/latest/documentation/api.html#step-by-step-guide
# Also available at docs/documentation/api.md.
-API_FEATURE_LEVEL = 485
+API_FEATURE_LEVEL = 486
# 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/web/src/abstract_gif_network.ts b/web/src/abstract_gif_network.ts
index d2e124c27b9..873b2b0217d 100644
--- a/web/src/abstract_gif_network.ts
+++ b/web/src/abstract_gif_network.ts
@@ -5,7 +5,7 @@ export type GifInfoUrl = {
export type RenderGifsCallback = (urls: GifInfoUrl[], next_page: boolean) => void;
-export type GifProvider = "tenor" | "giphy";
+export type GifProvider = "tenor" | "giphy" | "klipy";
// When a user clicks on the gif icon either while composing a
// message in the normal compose box or while editing a
// message, the UI will need to talk to a third party
diff --git a/web/src/admin.ts b/web/src/admin.ts
index 5599a32cfc2..1c508a6061a 100644
--- a/web/src/admin.ts
+++ b/web/src/admin.ts
@@ -147,7 +147,7 @@ export function build_page(): void {
}
let gif_help_link = "/help/animated-gifs";
- if (realm.giphy_api_key === "" && realm.tenor_api_key === "") {
+ if (realm.giphy_api_key === "" && realm.tenor_api_key === "" && realm.klipy_api_key === "") {
gif_help_link =
"https://zulip.readthedocs.io/en/latest/production/gif-picker-integrations.html";
}
@@ -161,7 +161,8 @@ export function build_page(): void {
realm_available_video_chat_providers: realm.realm_available_video_chat_providers,
server_jitsi_server_url: realm.server_jitsi_server_url,
gif_rating_policy_options: realm.gif_rating_policy_options,
- gif_api_key_empty: realm.giphy_api_key === "" && realm.tenor_api_key === "",
+ gif_api_key_empty:
+ realm.giphy_api_key === "" && realm.tenor_api_key === "" && realm.klipy_api_key === "",
realm_description_text: realm.realm_description,
realm_description_html: postprocess_content(page_params.realm_rendered_description),
realm_inline_image_preview: realm.realm_inline_image_preview,
diff --git a/web/src/gif_picker_popover_content.ts b/web/src/gif_picker_popover_content.ts
index 74ea4f49db9..66f31da84e6 100644
--- a/web/src/gif_picker_popover_content.ts
+++ b/web/src/gif_picker_popover_content.ts
@@ -14,11 +14,14 @@ export function get_gif_popover_content(provider: GifProvider): HTMLElement {
// We are required to include the
// "Powered By GIPHY" banner, which isn't mandatory
- // for Tenor. So we avoid including one for Tenor
- // to save space.
+ // for other providers. So we avoid including one to save space.
$picker.find(".popover-inner").append($(render_giphy_footer()));
} else {
- $picker.find("#gif-search-query").attr("placeholder", $t({defaultMessage: "Search Tenor"}));
+ const placeholder_text =
+ provider === "tenor"
+ ? $t({defaultMessage: "Search Tenor"})
+ : $t({defaultMessage: "Search KLIPY"});
+ $picker.find("#gif-search-query").attr("placeholder", placeholder_text);
}
return the<HTMLElement>($picker);
}
diff --git a/web/src/gif_picker_ui.ts b/web/src/gif_picker_ui.ts
index 191a92bacb4..1ce58afe5ce 100644
--- a/web/src/gif_picker_ui.ts
+++ b/web/src/gif_picker_ui.ts
@@ -11,6 +11,7 @@ import {ComposeIconSession} from "./compose_icon_session.ts";
import * as gif_picker_popover_content from "./gif_picker_popover_content.ts";
import * as gif_state from "./gif_state.ts";
import * as giphy_network from "./giphy_network.ts";
+import * as klipy_network from "./klipy_network.ts";
import * as popover_menus from "./popover_menus.ts";
import * as scroll_util from "./scroll_util.ts";
import * as tenor_network from "./tenor_network.ts";
@@ -269,9 +270,11 @@ function toggle_picker_popover(target: HTMLElement): void {
}
function get_gif_network(): GifNetwork {
- // We prefer Tenor over GIPHY.
+ // In terms of preference, Tenor > KLIPY > GIPHY.
if (gif_state.is_tenor_enabled()) {
return new tenor_network.TenorNetwork();
+ } else if (gif_state.is_klipy_enabled()) {
+ return new klipy_network.KlipyNetwork();
}
return new giphy_network.GiphyNetwork();
}
diff --git a/web/src/gif_state.ts b/web/src/gif_state.ts
index f40ed0e3c77..f0367b3ec03 100644
--- a/web/src/gif_state.ts
+++ b/web/src/gif_state.ts
@@ -12,6 +12,13 @@ export function is_tenor_enabled(): boolean {
);
}
+export function is_klipy_enabled(): boolean {
+ return (
+ realm.klipy_api_key !== "" &&
+ realm.realm_gif_rating_policy !== realm.gif_rating_policy_options.disabled.id
+ );
+}
+
export function is_giphy_enabled(): boolean {
return (
realm.giphy_api_key !== "" &&
diff --git a/web/src/klipy_network.ts b/web/src/klipy_network.ts
new file mode 100644
index 00000000000..8e3e558fb11
--- /dev/null
+++ b/web/src/klipy_network.ts
@@ -0,0 +1,134 @@
+import assert from "minimalistic-assert";
+import * as z from "zod/mini";
+
+import {
+ type GifInfoUrl,
+ GifNetwork,
+ type GifProvider,
+ type RenderGifsCallback,
+} from "./abstract_gif_network.ts";
+import * as channel from "./channel.ts";
+import {get_rating} from "./gif_state.ts";
+import {realm} from "./state_data.ts";
+import {user_settings} from "./user_settings.ts";
+
+const BASE_URL = "https://api.klipy.com/v2";
+
+const klipy_rating_map = {
+ // Source: https://docs.klipy.com/migrate-from-tenor/content-filtering
+ pg: "medium",
+ g: "high",
+ r: "off",
+ "pg-13": "low",
+};
+
+const klipy_result_schema = z.object({
+ results: z.array(
+ z.object({
+ media_formats: z.object({
+ tinygif: z.object({
+ url: z.url(),
+ }),
+ mediumgif: z.object({
+ url: z.url(),
+ }),
+ }),
+ }),
+ ),
+ // This denotes the identifier to use for the next API call
+ // to fetch the next set of results for the current query.
+ next: z.string(),
+});
+
+export type KlipyPayload = {
+ key: string;
+ limit: string;
+ media_filter: string;
+ locale: string;
+ contentfilter: string;
+ pos?: string | number | undefined;
+ q?: string;
+};
+
+export class KlipyNetwork extends GifNetwork {
+ is_loading_more = false;
+ next_pos_identifier: string | number | undefined;
+ abandoned = false;
+
+ get_provider(): GifProvider {
+ return "klipy";
+ }
+
+ is_loading_more_gifs(): boolean {
+ return this.is_loading_more;
+ }
+
+ abandon(): void {
+ this.abandoned = true;
+ }
+
+ ask_for_default_gifs(next_page: boolean, render_gifs_callback: RenderGifsCallback): void {
+ assert(!this.abandoned);
+ const data = get_base_payload();
+ this.ask_for_gifs(`${BASE_URL}/featured`, data, next_page, render_gifs_callback);
+ }
+
+ ask_for_search_gifs(
+ search_term: string,
+ next_page: boolean,
+ render_gifs_callback: RenderGifsCallback,
+ ): void {
+ assert(!this.abandoned);
+ const data: KlipyPayload = {
+ q: search_term,
+ ...get_base_payload(),
+ };
+
+ this.ask_for_gifs(`${BASE_URL}/search`, data, next_page, render_gifs_callback);
+ }
+
+ ask_for_gifs(
+ url: string,
+ data: KlipyPayload,
+ next_page = false,
+ render_gifs_callback: RenderGifsCallback,
+ ): void {
+ assert(!this.abandoned);
+ if (next_page) {
+ this.is_loading_more = true;
+ data = {...data, pos: this.next_pos_identifier};
+ }
+ void channel.get({
+ url,
+ data,
+ success: (raw_klipy_result) => {
+ // We don't want to have this code run after the caller
+ // abandons its network object, to avoid all sorts of weird
+ // bugs.
+ if (this.abandoned) {
+ return;
+ }
+ const parsed_data = klipy_result_schema.parse(raw_klipy_result);
+ const urls: GifInfoUrl[] = parsed_data.results.map((result) => ({
+ preview_url: result.media_formats.tinygif.url,
+ insert_url: result.media_formats.mediumgif.url,
+ }));
+ this.next_pos_identifier = parsed_data.next;
+ this.is_loading_more = false;
+ render_gifs_callback(urls, next_page);
+ },
+ });
+ }
+}
+
+function get_base_payload(): KlipyPayload {
+ return {
+ key: realm.klipy_api_key,
+ limit: "15",
+ // We use the tinygif size for the picker UI, and the mediumgif size
+ // for what gets actually uploaded.
+ media_filter: "tinygif,mediumgif",
+ locale: user_settings.default_language,
+ contentfilter: klipy_rating_map[get_rating()],
+ };
+}
diff --git a/web/src/state_data.ts b/web/src/state_data.ts
index c7802e79c6c..4ce74ab6c5e 100644
--- a/web/src/state_data.ts
+++ b/web/src/state_data.ts
@@ -617,6 +617,7 @@ export const realm_schema = z.object({
settings_send_digest_emails: z.boolean(),
stop_words: z.array(z.string()),
tenor_api_key: z.string(),
+ klipy_api_key: z.string(),
upgrade_text_for_wide_organization_logo: z.string(),
zulip_feature_level: z.number(),
zulip_merge_base: z.string(),
diff --git a/web/src/ui_init.js b/web/src/ui_init.js
index 26e1b9e1258..9fc2e0138df 100644
--- a/web/src/ui_init.js
+++ b/web/src/ui_init.js
@@ -225,6 +225,7 @@ function initialize_compose_box() {
giphy_enabled: gif_state.is_giphy_enabled(),
max_stream_name_length: realm.max_stream_name_length,
tenor_enabled: gif_state.is_tenor_enabled(),
+ klipy_enabled: gif_state.is_klipy_enabled(),
max_topic_length: realm.max_topic_length,
empty_string_topic_display_name: util.get_final_topic_display_name(""),
}),
diff --git a/web/templates/compose_control_buttons.hbs b/web/templates/compose_control_buttons.hbs
index 8c9a99de7d6..708d74b8c40 100644
--- a/web/templates/compose_control_buttons.hbs
+++ b/web/templates/compose_control_buttons.hbs
@@ -24,8 +24,8 @@
<div class="compose_control_button_container preview_mode_disabled compose_button_tooltip" data-tooltip-template-id="add-global-time-tooltip" data-tippy-maxWidth="none">
<a role="button" class="compose_control_button zulip-icon zulip-icon-time time_pick" aria-label="{{t 'Add global time' }}" tabindex=0></a>
</div>
- {{#if (or tenor_enabled giphy_enabled)}}
- {{!-- We prefer showing the Tenor picker over the GIPHY picker, if both are enabled. --}}
+ {{#if (or tenor_enabled giphy_enabled klipy_enabled)}}
+ {{!-- In terms of preference, Tenor > KLIPY > GIPHY. --}}
<div class="compose_control_button_container preview_mode_disabled compose_button_tooltip" data-tippy-content="{{t 'Add GIF' }}">
<a role="button" class="compose_control_button compose-gif-icon zulip-icon zulip-icon-gif" aria-label="{{t 'Add GIF' }}" tabindex=0></a>
</div>
diff --git a/zerver/lib/events.py b/zerver/lib/events.py
index dfb2f752079..b33b3b48546 100644
--- a/zerver/lib/events.py
+++ b/zerver/lib/events.py
@@ -954,10 +954,13 @@ def fetch_initial_state_data(
# abuse.
state["giphy_api_key"] = settings.GIPHY_API_KEY or ""
+ # See Giphy comment above; Tenor and KLIPY API keys work similarly.
if want("tenor"):
- # See Giphy comment above; Tenor API keys work similarly.
state["tenor_api_key"] = settings.TENOR_API_KEY or ""
+ if want("klipy"):
+ state["klipy_api_key"] = settings.KLIPY_API_KEY or ""
+
if want("device"):
state["devices"] = {} if user_profile is None else get_devices(user_profile)
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 820f27747a3..87a56015f2e 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -1000,6 +1000,7 @@ VIDEO_CALL_INTEGRATIONS: list[Integration] = [
EMBEDDED_INTEGRATIONS: list[Integration] = [
Integration("email", ["communication"]),
Integration("giphy", ["misc"], display_name="GIPHY"),
+ Integration("klipy", ["misc"], display_name="KLIPY"),
Integration("tenor", ["misc"], display_name="Tenor"),
]
@@ -1173,6 +1174,7 @@ INTEGRATIONS_WITHOUT_SCREENSHOTS = (
| {
# these integrations do not send messages
"giphy",
+ "klipy",
"nextcloud",
"tenor",
# the integration is planned to be removed
diff --git a/zerver/models/realms.py b/zerver/models/realms.py
index 38b4ecc5adf..d161cb08089 100644
--- a/zerver/models/realms.py
+++ b/zerver/models/realms.py
@@ -694,6 +694,7 @@ class Realm(models.Model):
# Source:
# 1. https://developers.giphy.com/docs/optional-settings/#rating
# 2. https://developers.google.com/tenor/guides/content-filtering#ContentFilter-options
+ # 3. https://docs.klipy.com/migrate-from-tenor/content-filtering
"g": {
"name": gettext_lazy("Allow GIFs rated G (General audience)"),
"id": 1,
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml
index 09e6b0efbf7..7ab0f7a6deb 100644
--- a/zerver/openapi/zulip.yaml
+++ b/zerver/openapi/zulip.yaml
@@ -19496,6 +19496,16 @@ paths:
[Tenor API TOS](https://developers.google.com/tenor/guides/api-terms).
**Changes**: New in Zulip 12.0 (feature level 442).
+ klipy_api_key:
+ type: string
+ description: |
+ Present if `klipy` is present in `fetch_event_types`.
+
+ KLIPY API keys are meant to be sent to the clients, see the
+ best practices in the [Migrate from Tenor documentation](https://docs.klipy.com/migrate-from-tenor/search#Best-practices).
+ Please don't use our API key for an app unrelated to Zulip.
+
+ **Changes**: New in Zulip 12.0 (feature level 486).
devices:
type: object
description: |
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index d36930a10f9..121624051e8 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -1294,6 +1294,7 @@ class FetchQueriesTest(ZulipTestCase):
device=1,
drafts=1,
giphy=0,
+ klipy=0,
tenor=0,
message=1,
muted_topics=1,
diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py
index a5dac13fe37..dfd3912cbe1 100644
--- a/zerver/tests/test_home.py
+++ b/zerver/tests/test_home.py
@@ -94,6 +94,7 @@ class HomeTest(ZulipTestCase):
"full_name",
"giphy_api_key",
"tenor_api_key",
+ "klipy_api_key",
"gif_rating_policy_options",
"has_zoom_token",
"idle_queue_timeout_secs",
diff --git a/zproject/default_settings.py b/zproject/default_settings.py
index 78200eba51e..3ea6521ec2f 100644
--- a/zproject/default_settings.py
+++ b/zproject/default_settings.py
@@ -192,6 +192,9 @@ GIPHY_API_KEY = get_secret("giphy_api_key")
# Tenor API key
TENOR_API_KEY = get_secret("tenor_api_key")
+# Klipy API key
+KLIPY_API_KEY = get_secret("klipy_api_key")
+
# Allow setting BigBlueButton settings in zulip-secrets.conf in
# development; this is useful since there are no public BigBlueButton servers.
BIG_BLUE_BUTTON_URL = get_secret("big_blue_button_url", development_only=True)
diff --git a/zproject/prod_settings_template.py b/zproject/prod_settings_template.py
index 93f305adbf1..eda89e93577 100644
--- a/zproject/prod_settings_template.py
+++ b/zproject/prod_settings_template.py
@@ -748,6 +748,7 @@ SOCIAL_AUTH_SAML_SUPPORT_CONTACT = {
## https://zulip.readthedocs.io/en/latest/production/gif-picker-integrations.html
# GIPHY_API_KEY = "<Your API key from GIPHY>"
# TENOR_API_KEY = "<Your API key from Tenor>"
+# KLIPY_API_KEY = "<Your API key from KLIPY>"
################
## Video call integrations.