Github integration (#6414)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2024-03-23 19:39:28 +05:30
committed by GitHub
parent a648625700
commit 450d0d9355
47 changed files with 1710 additions and 93 deletions

View File

@@ -57,10 +57,25 @@ export class CacheHelper {
/**
* Gets key against which unfurl response for the given url is stored
*
* @param url The url to generate a key for
* @param teamId The team ID to generate a key for
* @param url The url to generate a key for
*/
public static getUnfurlKey(url: string, teamId: string) {
public static getUnfurlKey(teamId: string, url = "") {
return `unfurl:${teamId}:${url}`;
}
/**
* Clears all cache data with the given prefix
*
* @param prefix Prefix to clear cache data
*/
public static async clearData(prefix: string) {
const keys = await Redis.defaultClient.keys(`${prefix}*`);
await Promise.all(
keys.map(async (key) => {
await Redis.defaultClient.del(key);
})
);
}
}

View File

@@ -3,7 +3,7 @@ import { glob } from "glob";
import type Router from "koa-router";
import isArray from "lodash/isArray";
import sortBy from "lodash/sortBy";
import { UnfurlSignature } from "@shared/types";
import { UnfurlSignature, UninstallSignature } from "@shared/types";
import type BaseEmail from "@server/emails/templates/BaseEmail";
import env from "@server/env";
import Logger from "@server/logging/Logger";
@@ -28,6 +28,7 @@ export enum Hook {
Processor = "processor",
Task = "task",
UnfurlProvider = "unfurl",
Uninstall = "uninstall",
}
/**
@@ -40,6 +41,7 @@ type PluginValueMap = {
[Hook.EmailTemplate]: typeof BaseEmail;
[Hook.Processor]: typeof BaseProcessor;
[Hook.Task]: typeof BaseTask<any>;
[Hook.Uninstall]: UninstallSignature;
[Hook.UnfurlProvider]: { unfurl: UnfurlSignature; cacheExpiry: number };
};