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:
@@ -89,13 +89,15 @@ router.post(
|
||||
)) as AuthenticationProvider[];
|
||||
|
||||
const data = AuthenticationHelper.providers
|
||||
.filter((p) => p.id !== "email")
|
||||
.filter((p) => p.value.id !== "email")
|
||||
.map((p) => {
|
||||
const row = teamAuthenticationProviders.find((t) => t.name === p.id);
|
||||
const row = teamAuthenticationProviders.find(
|
||||
(t) => t.name === p.value.id
|
||||
);
|
||||
|
||||
return {
|
||||
id: p.id,
|
||||
name: p.id,
|
||||
id: p.value.id,
|
||||
name: p.value.id,
|
||||
displayName: p.name,
|
||||
isEnabled: false,
|
||||
isConnected: false,
|
||||
|
||||
@@ -6,7 +6,7 @@ import env from "@server/env";
|
||||
import { NotFoundError } from "@server/errors";
|
||||
import coalesceBody from "@server/middlewares/coaleseBody";
|
||||
import { AppState, AppContext } from "@server/types";
|
||||
import { PluginManager, PluginType } from "@server/utils/PluginManager";
|
||||
import { Hook, PluginManager } from "@server/utils/PluginManager";
|
||||
import apiKeys from "./apiKeys";
|
||||
import attachments from "./attachments";
|
||||
import auth from "./auth";
|
||||
@@ -59,8 +59,8 @@ api.use(apiResponse());
|
||||
api.use(editor());
|
||||
|
||||
// Register plugin API routes before others to allow for overrides
|
||||
PluginManager.getEnabledPlugins(PluginType.API).forEach((plugin) =>
|
||||
router.use("/", plugin.value.routes())
|
||||
PluginManager.getHooks(Hook.API).forEach((hook) =>
|
||||
router.use("/", hook.value.routes())
|
||||
);
|
||||
|
||||
// routes
|
||||
|
||||
@@ -13,12 +13,12 @@ import { authorize } from "@server/policies";
|
||||
import { presentDocument, presentMention } from "@server/presenters/unfurls";
|
||||
import presentUnfurl from "@server/presenters/unfurls/unfurl";
|
||||
import { APIContext } from "@server/types";
|
||||
import { PluginManager, PluginType } from "@server/utils/PluginManager";
|
||||
import { Hook, PluginManager } from "@server/utils/PluginManager";
|
||||
import { RateLimiterStrategy } from "@server/utils/RateLimiter";
|
||||
import * as T from "./schema";
|
||||
|
||||
const router = new Router();
|
||||
const plugins = PluginManager.getEnabledPlugins(PluginType.UnfurlProvider);
|
||||
const plugins = PluginManager.getHooks(Hook.UnfurlProvider);
|
||||
|
||||
router.post(
|
||||
"urls.unfurl",
|
||||
|
||||
@@ -17,7 +17,7 @@ router.use(passport.initialize());
|
||||
|
||||
// dynamically load available authentication provider routes
|
||||
AuthenticationHelper.providers.forEach((provider) => {
|
||||
router.use("/", provider.value.routes());
|
||||
router.use("/", provider.value.router.routes());
|
||||
});
|
||||
|
||||
router.get("/redirect", auth(), async (ctx: APIContext) => {
|
||||
|
||||
Reference in New Issue
Block a user