refactor: move include head to opts
This commit is contained in:
parent
1124a040c8
commit
57397cc894
2 changed files with 8 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { Prisma } from "@prisma/client";
|
||||
import prisma from "../db";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatus from "../interfaces/http-status";
|
||||
|
|
@ -18,7 +19,10 @@ export function branchRelationPermInclude(user: RequestWithUser["user"]) {
|
|||
}
|
||||
|
||||
export function createPermCondition(globalAllow: (user: RequestWithUser["user"]) => boolean) {
|
||||
return (user: RequestWithUser["user"], alwaysIncludeHead?: boolean) =>
|
||||
return (
|
||||
user: RequestWithUser["user"],
|
||||
opts?: { alwaysIncludeHead?: boolean; includeInActive?: boolean },
|
||||
) =>
|
||||
isSystem(user)
|
||||
? undefined
|
||||
: [
|
||||
|
|
@ -27,7 +31,7 @@ export function createPermCondition(globalAllow: (user: RequestWithUser["user"])
|
|||
},
|
||||
{
|
||||
branch:
|
||||
alwaysIncludeHead || globalAllow(user)
|
||||
opts?.alwaysIncludeHead || globalAllow(user)
|
||||
? { some: { user: { some: { userId: user.sub } } } }
|
||||
: undefined,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue