mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
* fix: Scope external unfurl cache per user * test: Remove teammate unfurl cache test
34 lines
1.1 KiB
TypeScript
34 lines
1.1 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 CacheIssueSourcesTask from "../tasks/CacheIssueSourcesTask";
|
|
|
|
export default class IntegrationCreatedProcessor extends BaseProcessor {
|
|
static applicableEvents: Event["name"][] = ["integrations.create"];
|
|
|
|
async perform(event: IntegrationEvent) {
|
|
const integration = await Integration.findOne({
|
|
where: {
|
|
id: event.modelId,
|
|
},
|
|
paranoid: false,
|
|
});
|
|
if (integration?.type !== IntegrationType.Embed) {
|
|
return;
|
|
}
|
|
|
|
// Store the available issue sources in the integration record.
|
|
await new CacheIssueSourcesTask().schedule({
|
|
integrationId: integration.id,
|
|
});
|
|
|
|
// Clear the cache of unfurled data for the team as it may be stale now.
|
|
await CacheHelper.clearData(
|
|
RedisPrefixHelper.getUnfurlPrefix(integration.teamId)
|
|
);
|
|
}
|
|
}
|