mirror of
https://github.com/outline/outline.git
synced 2026-12-06 11:12:32 +03:00
* wip * fix: Address review feedback on Granola integration - Limit the size of Granola API responses - Load the team when authorizing notes into personal collections - Add the user's connection from granola.list to the integrations store * feat: Connect Granola from a dialog * fix: Accept Granola webhook test events * Copy pass * Copy pass
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import { toError } from "@shared/utils/error";
|
|
import type { IntegrationType } from "@shared/types";
|
|
import { IntegrationService } from "@shared/types";
|
|
import Logger from "@server/logging/Logger";
|
|
import type { Integration } from "@server/models";
|
|
import { PluginManager, Hook } from "@server/utils/PluginManager";
|
|
import config from "../plugin.json";
|
|
import router from "./api/granola";
|
|
import { Granola } from "./granola";
|
|
import GranolaNoteTask from "./tasks/GranolaNoteTask";
|
|
|
|
PluginManager.add([
|
|
{
|
|
...config,
|
|
type: Hook.API,
|
|
value: router,
|
|
},
|
|
{
|
|
type: Hook.IntegrationSettings,
|
|
value: {
|
|
service: IntegrationService.Granola,
|
|
keys: ["granola"],
|
|
},
|
|
},
|
|
{
|
|
type: Hook.Task,
|
|
value: GranolaNoteTask,
|
|
},
|
|
{
|
|
type: Hook.Uninstall,
|
|
value: async (integration: Integration) => {
|
|
if (integration.service !== IntegrationService.Granola) {
|
|
return;
|
|
}
|
|
|
|
const settings = (
|
|
integration as Integration<IntegrationType.LinkedAccount>
|
|
).settings?.granola;
|
|
const authentication = await integration.$get("authentication");
|
|
if (!settings || !authentication) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
await Granola.deleteWebhookEndpoint(
|
|
authentication.token,
|
|
settings.webhookEndpointId
|
|
);
|
|
} catch (err) {
|
|
// Best effort, Granola disables the endpoint when deliveries fail.
|
|
Logger.error("Failed to delete Granola webhook endpoint", toError(err));
|
|
}
|
|
},
|
|
},
|
|
]);
|