Github integration (#6414)
Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
24
server/queues/processors/IntegrationCreatedProcessor.ts
Normal file
24
server/queues/processors/IntegrationCreatedProcessor.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { IntegrationType } from "@shared/types";
|
||||
import { Integration } from "@server/models";
|
||||
import BaseProcessor from "@server/queues/processors/BaseProcessor";
|
||||
import { IntegrationEvent, Event } from "@server/types";
|
||||
import { CacheHelper } from "@server/utils/CacheHelper";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Clear the cache of unfurled data for the team as it may be stale now.
|
||||
await CacheHelper.clearData(CacheHelper.getUnfurlKey(integration.teamId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user