mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-04 22:02:16 +02:00
fix(zero):scope content workspace queries
This commit is contained in:
parent
737d63f3dc
commit
be95f65c6b
3 changed files with 20 additions and 11 deletions
|
|
@ -1,9 +1,12 @@
|
|||
import { defineQuery } from "@rocicorp/zero";
|
||||
import { z } from "zod";
|
||||
import { zql } from "../schema/index";
|
||||
import { canReadSpace, constrainToAllowedSpaces, denySpace } from "./authz";
|
||||
|
||||
export const folderQueries = {
|
||||
bySpace: defineQuery(z.object({ searchSpaceId: z.number() }), ({ args: { searchSpaceId } }) =>
|
||||
zql.folders.where("searchSpaceId", searchSpaceId).orderBy("position", "asc")
|
||||
),
|
||||
bySpace: defineQuery(z.object({ searchSpaceId: z.number() }), ({ args: { searchSpaceId }, ctx }) => {
|
||||
const query = zql.folders.where("searchSpaceId", searchSpaceId);
|
||||
if (!canReadSpace(ctx, searchSpaceId)) return denySpace(query).orderBy("position", "asc");
|
||||
return constrainToAllowedSpaces(query, ctx).orderBy("position", "asc");
|
||||
}),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue