Plugin architecture (#4861)

* wip

* Refactor, tasks, processors, routes loading

* Move Slack settings config to plugin

* Fix translations in plugins

* Move Slack auth to plugin

* test

* Move other slack-related files into plugin

* Forgot to save

* refactor
This commit is contained in:
Tom Moor
2023-02-12 13:11:30 -05:00
committed by GitHub
parent 492beedf00
commit 33afa2f029
30 changed files with 273 additions and 117 deletions

View File

@@ -18,7 +18,6 @@ import presentProviderConfig from "./providerConfig";
import presentRevision from "./revision";
import presentSearchQuery from "./searchQuery";
import presentShare from "./share";
import presentSlackAttachment from "./slackAttachment";
import presentStar from "./star";
import presentSubscription from "./subscription";
import presentTeam from "./team";
@@ -48,7 +47,6 @@ export {
presentRevision,
presentSearchQuery,
presentShare,
presentSlackAttachment,
presentStar,
presentSubscription,
presentTeam,

View File

@@ -1,4 +1,4 @@
import { signin } from "@shared/utils/urlHelpers";
import { signin } from "@shared/utils/routeHelpers";
import { AuthenticationProviderConfig } from "@server/routes/auth/providers";
export default function presentProviderConfig(

View File

@@ -1,38 +0,0 @@
import { traceFunction } from "@server/logging/tracing";
import { Document, Collection, Team } from "@server/models";
type Action = {
type: string;
text: string;
name: string;
value: string;
};
function presentSlackAttachment(
document: Document,
team: Team,
collection?: Collection | null,
context?: string,
actions?: Action[]
) {
// the context contains <b> tags around search terms, we convert them here
// to the markdown format that slack expects to receive.
const text = context
? context.replace(/<\/?b>/g, "*").replace(/\n/g, "")
: document.getSummary();
return {
color: collection?.color,
title: document.title,
title_link: `${team.url}${document.url}`,
footer: collection?.name,
callback_id: document.id,
text,
ts: document.getTimestamp(),
actions,
};
}
export default traceFunction({
spanName: "presenters",
})(presentSlackAttachment);