Files
outline/server/policies/attachment.ts
2024-03-31 17:28:35 -07:00

13 lines
379 B
TypeScript

import { Attachment, User, Team } from "@server/models";
import { allow } from "./cancan";
import { and, isOwner, isTeamModel, or } from "./utils";
allow(User, "createAttachment", Team, isTeamModel);
allow(User, ["read", "update", "delete"], Attachment, (actor, attachment) =>
and(
isTeamModel(actor, attachment),
or(actor.isAdmin, isOwner(actor, attachment))
)
);