mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
fix: migrate gifs to klipy service (#1220)
This commit is contained in:
1 parent
99eedf6d1e
commit
4a741d8396
79 files changed
+3032
-1653
No files matched your search
@@ -63,7 +63,6 @@ const LANE_CONFIG = {
|
||||
batch: {
|
||||
consumerName: 'workers_batch',
|
||||
tasks: [
|
||||
'enqueueGifFeaturedCategoriesRefresh',
|
||||
'expireAttachments',
|
||||
'indexChannelMessages',
|
||||
'indexGuildMembers',
|
||||
@@ -74,7 +73,6 @@ const LANE_CONFIG = {
|
||||
'processPendingBulkMessageDeletions',
|
||||
'processPremiumStateReconciliationQueue',
|
||||
'prunePostgresKvTtl',
|
||||
'refreshGifFeaturedCategories',
|
||||
'refreshSearchIndex',
|
||||
'syncDiscoveryIndex',
|
||||
'syncDisposableEmailDomains',
|
||||
|
||||
@@ -52,7 +52,6 @@ function registerCronJobs(cron: CronScheduler): void {
|
||||
cron.upsert('prunePostgresKvTtl', 'prunePostgresKvTtl', {}, '0 */5 * * * *');
|
||||
cron.upsert('syncDiscoveryIndex', 'syncDiscoveryIndex', {}, '0 */15 * * * *');
|
||||
cron.upsert('syncDisposableEmailDomains', 'syncDisposableEmailDomains', {}, '0 */30 * * * *');
|
||||
cron.upsert('enqueueGifFeaturedCategoriesRefresh', 'enqueueGifFeaturedCategoriesRefresh', {}, '0 */30 * * * *');
|
||||
cron.upsert('syncUrlBlocklists', 'syncUrlBlocklists', {}, '0 0 */6 * * *');
|
||||
cron.upsert('syncFileShaBlocklists', 'syncFileShaBlocklists', {}, '0 0 */12 * * *');
|
||||
cron.upsert('flushUserActivityBuffer', 'flushUserActivityBuffer', {}, '*/10 * * * * *');
|
||||
|
||||
@@ -13,7 +13,6 @@ import bulkDeleteSelfMessagesImmediate from './tasks/BulkDeleteSelfMessagesImmed
|
||||
import bulkDeleteUserMessages from './tasks/BulkDeleteUserMessages';
|
||||
import bulkDeleteUserMessagesScoped from './tasks/BulkDeleteUserMessagesScoped';
|
||||
import deleteUserMessagesInGuildByTime from './tasks/DeleteUserMessagesInGuildByTime';
|
||||
import enqueueGifFeaturedCategoriesRefresh from './tasks/EnqueueGifFeaturedCategoriesRefresh';
|
||||
import expireAttachments from './tasks/ExpireAttachments';
|
||||
import extractEmbeds from './tasks/ExtractEmbeds';
|
||||
import finalizeNcmecAttachmentReport from './tasks/FinalizeNcmecAttachmentReport';
|
||||
@@ -34,7 +33,6 @@ import processPremiumStateReconciliationQueue from './tasks/ProcessPremiumStateR
|
||||
import processStripeWebhook from './tasks/ProcessStripeWebhook';
|
||||
import prunePostgresKvTtl from './tasks/PrunePostgresKvTtl';
|
||||
import reconcileUserPayments from './tasks/ReconcileUserPayments';
|
||||
import refreshGifFeaturedCategories from './tasks/RefreshGifFeaturedCategories';
|
||||
import refreshSearchIndex from './tasks/RefreshSearchIndex';
|
||||
import revalidateUserConnections from './tasks/RevalidateUserConnections';
|
||||
import {sendScheduledMessage} from './tasks/SendScheduledMessage';
|
||||
@@ -60,7 +58,6 @@ export const workerTasks: Record<WorkerTaskName, WorkerTaskHandler> = {
|
||||
bulkUpdateSuspiciousActivityFlags: bulkUpdateSuspiciousActivityFlags,
|
||||
bulkUpdateUserFlags: bulkUpdateUserFlags,
|
||||
deleteUserMessagesInGuildByTime,
|
||||
enqueueGifFeaturedCategoriesRefresh,
|
||||
expireAttachments,
|
||||
extractEmbeds,
|
||||
finalizeNcmecAttachmentReport,
|
||||
@@ -80,7 +77,6 @@ export const workerTasks: Record<WorkerTaskName, WorkerTaskHandler> = {
|
||||
processPremiumStateReconciliationQueue,
|
||||
reconcileUserPayments,
|
||||
prunePostgresKvTtl,
|
||||
refreshGifFeaturedCategories,
|
||||
refreshSearchIndex,
|
||||
revalidateUserConnections,
|
||||
sendScheduledMessage,
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask';
|
||||
import {listSeenLocales} from '../../gif/GifFeaturedCategoriesCache';
|
||||
import {getGifService} from '../../middleware/ServiceSingletons';
|
||||
import {getWorkerDependencies} from '../WorkerContext';
|
||||
|
||||
const enqueueGifFeaturedCategoriesRefresh: WorkerTaskHandler = async (_payload, helpers) => {
|
||||
const {cacheService, workerService} = getWorkerDependencies();
|
||||
const gifService = getGifService();
|
||||
for (const provider of gifService.listProviders()) {
|
||||
if (!(await provider.isAvailable())) continue;
|
||||
const locales = await listSeenLocales(cacheService, provider.meta.name);
|
||||
if (locales.length === 0) {
|
||||
helpers.logger.debug({provider: provider.meta.name}, 'No seen locales for GIF provider; nothing to refresh');
|
||||
continue;
|
||||
}
|
||||
helpers.logger.debug(
|
||||
{provider: provider.meta.name, count: locales.length},
|
||||
'Fanning out enriched GIF categories refresh',
|
||||
);
|
||||
for (const {locale, country} of locales) {
|
||||
try {
|
||||
await workerService.addJob('refreshGifFeaturedCategories', {
|
||||
provider: provider.meta.name,
|
||||
locale,
|
||||
country,
|
||||
});
|
||||
} catch (error) {
|
||||
helpers.logger.warn(
|
||||
{err: error, provider: provider.meta.name, locale, country},
|
||||
'Failed to enqueue per-locale GIF categories refresh',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default enqueueGifFeaturedCategoriesRefresh;
|
||||
@@ -1,33 +0,0 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import type {WorkerTaskHandler} from '@pkgs/worker/src/contracts/WorkerTask';
|
||||
import {getGifService} from '../../middleware/ServiceSingletons';
|
||||
|
||||
interface RefreshPayload {
|
||||
provider?: string;
|
||||
locale?: string;
|
||||
country?: string;
|
||||
}
|
||||
|
||||
const refreshGifFeaturedCategories: WorkerTaskHandler = async (rawPayload, helpers) => {
|
||||
const payload = (rawPayload ?? {}) as RefreshPayload;
|
||||
const {provider, locale, country} = payload;
|
||||
if (!provider || !locale || !country) {
|
||||
helpers.logger.warn({payload}, 'refreshGifFeaturedCategories called without required fields');
|
||||
return;
|
||||
}
|
||||
const gifService = getGifService();
|
||||
const target = gifService.getByName(provider);
|
||||
if (!target) {
|
||||
helpers.logger.warn({provider}, 'refreshGifFeaturedCategories: unknown provider');
|
||||
return;
|
||||
}
|
||||
if (!(await target.isAvailable())) {
|
||||
helpers.logger.debug({provider}, 'refreshGifFeaturedCategories: provider not configured, skipping');
|
||||
return;
|
||||
}
|
||||
helpers.logger.debug({provider, locale, country}, 'Refreshing enriched GIF featured categories');
|
||||
await target.refreshFeaturedCategories({locale, country});
|
||||
};
|
||||
|
||||
export default refreshGifFeaturedCategories;
|
||||
Reference in new issue
Block a user