fix: migrate gifs to klipy service (#1220)

This commit is contained in:
Hampus authored and GitHub committed 2026-06-30 01:19:57 +02:00
1 parent 99eedf6d1e
commit 4a741d8396
79 files changed
+3032 -1653

No files matched your search

@@ -99,13 +99,10 @@ interface InstanceServicesPublicConfig {
bluesky_enabled: boolean;
}
export type InstanceGifProvider = 'tenor' | 'klipy';
export type InstanceCaptchaProvider = 'hcaptcha' | 'turnstile' | 'none';
type InstanceEmailProvider = 'smtp' | 'none';
interface InstanceGifIntegrationConfig {
provider: InstanceGifProvider | null;
tenor_api_key: string | null;
klipy_api_key: string | null;
}
@@ -160,9 +157,7 @@ interface InstanceIntegrationsConfig {
bluesky: InstanceBlueskyIntegrationConfig;
}
export interface InstanceGifEffectiveConfig {
provider: InstanceGifProvider;
tenor_api_key: string | null;
interface InstanceGifEffectiveConfig {
klipy_api_key: string | null;
active_api_key: string | null;
available: boolean;
@@ -179,9 +174,6 @@ export interface InstanceCaptchaEffectiveConfig {
interface InstanceIntegrationsAdminConfig {
gif: {
provider: InstanceGifProvider | null;
effective_provider: InstanceGifProvider;
tenor_api_key_set: boolean;
klipy_api_key_set: boolean;
effective_available: boolean;
};
@@ -438,8 +430,6 @@ function normalizeInstancePolicyConfig(value: unknown): InstancePolicyConfig {
const DEFAULT_INSTANCE_INTEGRATIONS_CONFIG: InstanceIntegrationsConfig = {
gif: {
provider: null,
tenor_api_key: null,
klipy_api_key: null,
},
youtube: {
@@ -492,10 +482,6 @@ const DEFAULT_INSTANCE_MEDIA_CONFIG: InstanceMediaConfig = {
attachment_decay: DEFAULT_INSTANCE_ATTACHMENT_DECAY_CONFIG,
};
function isGifProvider(value: unknown): value is InstanceGifProvider {
return value === 'tenor' || value === 'klipy';
}
function isCaptchaProvider(value: unknown): value is InstanceCaptchaProvider {
return value === 'hcaptcha' || value === 'turnstile' || value === 'none';
}
@@ -561,8 +547,6 @@ function normalizeInstanceIntegrationsConfig(value: unknown): InstanceIntegratio
: defaults.bluesky.keys;
return {
gif: {
provider: isGifProvider(gif.provider) ? gif.provider : defaults.gif.provider,
tenor_api_key: normalizeSecretString(gif.tenor_api_key),
klipy_api_key: normalizeSecretString(gif.klipy_api_key),
},
youtube: {
@@ -1214,16 +1198,11 @@ export class InstanceConfigRepository {
async getEffectiveGifConfig(): Promise<InstanceGifEffectiveConfig> {
const integrations = await this.getInstanceIntegrationsConfig();
const provider = integrations.gif.provider ?? Config.gif.provider;
const tenorApiKey = integrations.gif.tenor_api_key ?? normalizeSecretString(Config.tenor.apiKey);
const klipyApiKey = integrations.gif.klipy_api_key ?? normalizeSecretString(Config.klipy.apiKey);
const activeApiKey = provider === 'tenor' ? tenorApiKey : klipyApiKey;
return {
provider,
tenor_api_key: tenorApiKey,
klipy_api_key: klipyApiKey,
active_api_key: activeApiKey,
available: Boolean(activeApiKey),
active_api_key: klipyApiKey,
available: Boolean(klipyApiKey),
};
}
@@ -1323,9 +1302,6 @@ export class InstanceConfigRepository {
]);
return {
gif: {
provider: integrations.gif.provider,
effective_provider: gif.provider,
tenor_api_key_set: secretIsSet(integrations.gif.tenor_api_key) || secretIsSet(Config.tenor.apiKey),
klipy_api_key_set: secretIsSet(integrations.gif.klipy_api_key) || secretIsSet(Config.klipy.apiKey),
effective_available: gif.available,
},