chore: Plugin registration (#6623)

* first pass

* test

* test

* priority

* Reduce boilerplate further

* Update server/utils/PluginManager.ts

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>

* fix: matchesNode error in destroyed editor transaction

* fix: Individual imported files do not display source correctly in 'Insights'

* chore: Add sleep before Slack notification

* docs

* fix: Error logged about missing plugin.json

* Remove email template glob

---------

Co-authored-by: Apoorv Mishra <apoorvmishra101092@gmail.com>
This commit is contained in:
Tom Moor
2024-03-08 21:32:05 -07:00
committed by GitHub
parent f3334cedb2
commit f9a11a28d8
43 changed files with 400 additions and 276 deletions

View File

@@ -13,11 +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 { RateLimiterStrategy } from "@server/utils/RateLimiter";
import resolvers from "@server/utils/unfurl";
import * as T from "./schema";
const router = new Router();
const plugins = PluginManager.getEnabledPlugins(PluginType.UnfurlProvider);
router.post(
"urls.unfurl",
@@ -74,11 +75,13 @@ router.post(
}
// External resources
if (resolvers.Iframely) {
const data = await resolvers.Iframely.unfurl(url);
return data.error
? (ctx.response.status = 204)
: (ctx.body = presentUnfurl(data));
for (const plugin of plugins) {
const data = await plugin.value(url);
if (data) {
return "error" in data
? (ctx.response.status = 204)
: (ctx.body = presentUnfurl(data));
}
}
return (ctx.response.status = 204);