PluginManager refactor (#6677)

* fix: refactor plugin manager

* fix: make id optional

* fix: allow add to accept single object

* fix: getHooks

* fix: tsc

* fix: remove id
This commit is contained in:
Apoorv Mishra
2024-03-16 21:22:25 +05:30
committed by GitHub
parent 6775f25425
commit 85c8f83e33
20 changed files with 187 additions and 178 deletions

View File

@@ -1,15 +1,21 @@
import {
PluginManager,
PluginPriority,
PluginType,
Hook,
} from "@server/utils/PluginManager";
import env from "./env";
import Iframely from "./iframely";
PluginManager.register(PluginType.UnfurlProvider, Iframely.get, {
id: "iframely",
enabled: !!env.IFRAMELY_API_KEY && !!env.IFRAMELY_URL,
const enabled = !!env.IFRAMELY_API_KEY && !!env.IFRAMELY_URL;
// Make sure this is last in the stack to be evaluated after all other unfurl providers
priority: PluginPriority.VeryLow,
});
if (enabled) {
PluginManager.add([
{
type: Hook.UnfurlProvider,
value: Iframely.get,
// Make sure this is last in the stack to be evaluated after all other unfurl providers
priority: PluginPriority.VeryLow,
},
]);
}