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
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { IntegrationType } from "@shared/types";
|
|
import { Integration, User, Team } from "@server/models";
|
|
import { allow } from "./cancan";
|
|
import {
|
|
and,
|
|
isOwner,
|
|
isTeamAdmin,
|
|
isTeamModel,
|
|
isTeamMutable,
|
|
or,
|
|
} from "./utils";
|
|
|
|
allow(User, "createIntegration", Team, (actor, team) =>
|
|
and(isTeamAdmin(actor, team), isTeamMutable(actor))
|
|
);
|
|
|
|
allow(User, "read", Integration, (actor, integration) =>
|
|
and(
|
|
isTeamModel(actor, integration),
|
|
integration?.type === IntegrationType.LinkedAccount
|
|
? isOwner(actor, integration)
|
|
: !actor.isGuest || integration?.type === IntegrationType.Embed
|
|
)
|
|
);
|
|
|
|
// A linked account acts as its owner, so only the owner may change it.
|
|
allow(User, "update", Integration, (actor, integration) =>
|
|
and(
|
|
isTeamModel(actor, integration),
|
|
isTeamMutable(actor),
|
|
!actor.isGuest,
|
|
!actor.isViewer,
|
|
integration?.type === IntegrationType.LinkedAccount
|
|
? isOwner(actor, integration)
|
|
: actor.isAdmin
|
|
)
|
|
);
|
|
|
|
allow(User, "delete", Integration, (actor, integration) =>
|
|
and(
|
|
isTeamModel(actor, integration),
|
|
isTeamMutable(actor),
|
|
!actor.isGuest,
|
|
!actor.isViewer,
|
|
or(
|
|
actor.isAdmin,
|
|
isOwner(actor, integration) &&
|
|
integration.type === IntegrationType.LinkedAccount
|
|
)
|
|
)
|
|
);
|