feat: Support embed configuration (#3980)

* wip

* stash

* fix: make authenticationId nullable fk

* fix: apply generics to resolve compile time type errors

* fix: loosen integration settings

* chore: refactor into functional component

* feat: pass integrations all the way to embeds

* perf: avoid re-fetching integrations

* fix: change attr name to avoid type overlap

* feat: use hostname from embed settings in matcher

* Revert "feat: use hostname from embed settings in matcher"

This reverts commit e7485d9cda4dcf45104e460465ca104a56c67ddc.

* feat: refactor  into a class

* chore: refactor url regex formation as a util

* fix: escape regex special chars

* fix: remove in-house escapeRegExp in favor of lodash's

* fix: sanitize url

* perf: memoize embeds

* fix: rename hostname to url and allow spreading entire settings instead of just url

* fix: replace diagrams with drawio

* fix: rename

* fix: support self-hosted and saas both

* fix: assert on settings url

* fix: move embed integrations loading to hook

* fix: address review comments

* fix: use observer in favor of explicit state setters

* fix: refactor useEmbedIntegrations into useEmbeds

* fix: use translations for toasts

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2022-08-26 12:21:46 +05:30
committed by GitHub
parent 24c71c38a5
commit 4dbad4e46c
24 changed files with 499 additions and 216 deletions

View File

@@ -1,5 +1,6 @@
import fetch from "fetch-with-proxy";
import { Op } from "sequelize";
import { IntegrationType } from "@shared/types";
import env from "@server/env";
import { Document, Integration, Collection, Team } from "@server/models";
import { presentSlackAttachment } from "@server/presenters";
@@ -32,7 +33,7 @@ export default class SlackProcessor extends BaseProcessor {
}
async integrationCreated(event: IntegrationEvent) {
const integration = await Integration.findOne({
const integration = (await Integration.findOne({
where: {
id: event.modelId,
service: "slack",
@@ -45,7 +46,7 @@ export default class SlackProcessor extends BaseProcessor {
as: "collection",
},
],
});
})) as Integration<IntegrationType.Post>;
if (!integration) {
return;
}
@@ -93,7 +94,7 @@ export default class SlackProcessor extends BaseProcessor {
return;
}
const integration = await Integration.findOne({
const integration = (await Integration.findOne({
where: {
teamId: document.teamId,
collectionId: document.collectionId,
@@ -105,7 +106,7 @@ export default class SlackProcessor extends BaseProcessor {
],
},
},
});
})) as Integration<IntegrationType.Post>;
if (!integration) {
return;
}