mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* chore: Make app compatible with Fluid Compute * Removed isCold from me api endpoint * chore: Remove handler caching for Fluid Compute compatibility (#20692) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> * fix client_id issue * chore: Remove UNSTABLE_HANDLER_CACHE for Fluid Compute compatibility (#20694) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]> * Fixing types * Fixing type issues * chore: Remove importHandler references for Fluid Compute compatibility Co-Authored-By: [email protected] <[email protected]> * chore: Remove importHandler references from attributes router for Fluid Compute compatibility Co-Authored-By: [email protected] <[email protected]> --------- Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { HttpError } from "@calcom/lib/http-error";
|
|
|
|
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
|
|
|
|
const checkGiphyApiKey = async () => {
|
|
const appKeys = await getAppKeysFromSlug("giphy");
|
|
if (typeof appKeys.api_key === "string") return appKeys.api_key;
|
|
throw new HttpError({ statusCode: 400, message: "Missing Giphy api_key" });
|
|
};
|
|
|
|
export const searchGiphy = async (locale: string, keyword: string, offset = 0) => {
|
|
const apiKey = await checkGiphyApiKey();
|
|
const queryParams = new URLSearchParams({
|
|
api_key: apiKey,
|
|
q: keyword,
|
|
limit: "1",
|
|
offset: String(offset),
|
|
// Contains images that are broadly accepted as appropriate and commonly witnessed by people in a public environment.
|
|
rating: "g",
|
|
lang: locale,
|
|
});
|
|
const response = await fetch(`https://api.giphy.com/v1/gifs/search?${queryParams.toString()}`, {
|
|
method: "GET",
|
|
headers: {
|
|
Accept: "application/json",
|
|
},
|
|
});
|
|
const responseBody = await response.json();
|
|
const gifs = responseBody.data;
|
|
return {
|
|
gifImageUrl: gifs?.[0]?.images?.fixed_height_downsampled?.url || null,
|
|
total: responseBody.pagination.total_count,
|
|
};
|
|
};
|
|
|
|
export const getGiphyById = async (giphyId: string) => {
|
|
const apiKey = await checkGiphyApiKey();
|
|
const queryParams = new URLSearchParams({
|
|
api_key: apiKey,
|
|
});
|
|
const response = await fetch(`https://api.giphy.com/v1/gifs/${giphyId}?${queryParams.toString()}`, {
|
|
method: "GET",
|
|
headers: {
|
|
Accept: "application/json",
|
|
},
|
|
});
|
|
const responseBody = await response.json();
|
|
const gifs = responseBody.data;
|
|
return gifs?.images?.fixed_height_downsampled?.url || null;
|
|
};
|