({
ctx,
input,
}: InferProcedureOpts<typeof baseProcedure>)
| 16 | export const createProcedure = once(() => baseProcedure.mutation(create)); |
| 17 | |
| 18 | export async function create({ |
| 19 | ctx, |
| 20 | input, |
| 21 | }: InferProcedureOpts<typeof baseProcedure>) { |
| 22 | // Check if user has sufficient permissions |
| 23 | |
| 24 | const [sourceGroupId, targetGroupId] = await ctx.dataAbstraction.mhget([ |
| 25 | hget('page', input.sourcePageId, 'group-id'), |
| 26 | hget('page', input.targetPageId, 'group-id'), |
| 27 | ]); |
| 28 | |
| 29 | await ctx.assertSufficientGroupPermissions({ |
| 30 | userId: ctx.userId, |
| 31 | groupId: sourceGroupId, |
| 32 | permission: 'editGroupPages', |
| 33 | }); |
| 34 | |
| 35 | await ctx.assertSufficientGroupPermissions({ |
| 36 | userId: ctx.userId, |
| 37 | groupId: targetGroupId, |
| 38 | permission: 'editGroupPages', |
| 39 | }); |
| 40 | |
| 41 | // Create page link |
| 42 | |
| 43 | await addPageBacklink({ |
| 44 | targetPageId: input.targetPageId, |
| 45 | sourcePageId: input.sourcePageId, |
| 46 | dataAbstraction: ctx.dataAbstraction, |
| 47 | }); |
| 48 | } |
nothing calls this directly
no test coverage detected