Files
outline/server/queues/processors/IntegrationDeletedProcessor.ts
40bbfc78cd Refactor: Extract Redis cache key generation to RedisPrefixHelper (#11376)
* Initial plan

* Refactor Redis cache keys: delegate CacheHelper to RedisPrefixHelper and update callers

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Add JSDoc documentation to getCollectionDocumentsKey method

Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>

* Remove unused indirection

* Remove mock

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tommoor <380914+tommoor@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
2026-02-09 14:03:02 -05:00

36 lines
1.2 KiB
TypeScript

import { IntegrationType } from "@shared/types";
import { Integration } from "@server/models";
import BaseProcessor from "@server/queues/processors/BaseProcessor";
import type { IntegrationEvent, Event } from "@server/types";
import { CacheHelper } from "@server/utils/CacheHelper";
import { RedisPrefixHelper } from "@server/utils/RedisPrefixHelper";
import { Hook, PluginManager } from "@server/utils/PluginManager";
export default class IntegrationDeletedProcessor extends BaseProcessor {
static applicableEvents: Event["name"][] = ["integrations.delete"];
async perform(event: IntegrationEvent) {
const integration = await Integration.findOne({
where: {
id: event.modelId,
},
paranoid: false,
});
if (!integration) {
return;
}
const uninstallHooks = PluginManager.getHooks(Hook.Uninstall);
for (const hook of uninstallHooks) {
await hook.value(integration);
}
// Clear the cache of unfurled data for the team as it may be stale now.
if (integration.type === IntegrationType.Embed) {
await CacheHelper.clearData(RedisPrefixHelper.getUnfurlKey(integration.teamId));
}
await integration.destroy({ force: true });
}
}