Files
outline/plugins/github/server/index.ts
Hemachandar 7d315288dd Listen to GitHub webhooks to update issueSources cache (#9414)
* Listen to GitHub webhooks to update issue-sources cache

* Add `GitHubWebhookTask`

* review
2025-07-15 23:07:14 -04:00

43 lines
1018 B
TypeScript

import { Minute } from "@shared/utils/time";
import { PluginManager, Hook } from "@server/utils/PluginManager";
import config from "../plugin.json";
import { GitHubIssueProvider } from "./GitHubIssueProvider";
import router from "./api/github";
import env from "./env";
import { GitHub } from "./github";
import GitHubWebhookTask from "./tasks/GitHubWebhookTask";
import { uninstall } from "./uninstall";
const enabled =
!!env.GITHUB_CLIENT_ID &&
!!env.GITHUB_CLIENT_SECRET &&
!!env.GITHUB_APP_NAME &&
!!env.GITHUB_APP_ID &&
!!env.GITHUB_APP_PRIVATE_KEY;
if (enabled) {
PluginManager.add([
{
...config,
type: Hook.API,
value: router,
},
{
type: Hook.Task,
value: GitHubWebhookTask,
},
{
type: Hook.IssueProvider,
value: new GitHubIssueProvider(),
},
{
type: Hook.UnfurlProvider,
value: { unfurl: GitHub.unfurl, cacheExpiry: Minute.seconds },
},
{
type: Hook.Uninstall,
value: uninstall,
},
]);
}