Files
calendar/packages/trpc/server/routers/viewer/workflows/get.handler.ts
T
Benny JooandGitHub ff38d6c7db refactor: Remove circular deps between @calcom/lib and @calcom/features [1] (#24399)
* add eslint config

* migrate autoLock to features

* migrate teamService to features

* migrate userCreationService

* migrate insights services to features

* migrate ProfileRepository

* update imports

* migrate filter segmen tests

* migrate filter segment repository

* migrate getBusyTimes

* migrate getLocaleFromRequest

* refactor csvUtils

* make filename clearer

* migrate getLuckyUser integration test

* migrate autoLock test to features

* wip

* refactors

* migrate useBookerUrl

* migrate more

* wip

* Migrate eventTypeRepository

* membership repository

* update imports

* update imports

* migrate

* move organization repository

* update imports

* update imports

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix tests

* fix type checks

* fix

* fix

* migrate

* update imports

* fix tests

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix
2025-10-13 12:01:02 -03:00

37 lines
1.0 KiB
TypeScript

import { WorkflowRepository } from "@calcom/features/ee/workflows/repositories/WorkflowRepository";
import { addPermissionsToWorkflow } from "@calcom/lib/server/repository/workflow-permissions";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
import { TRPCError } from "@trpc/server";
import type { TGetInputSchema } from "./get.schema";
import { isAuthorized } from "./util";
type GetOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
input: TGetInputSchema;
};
export const getHandler = async ({ ctx, input }: GetOptions) => {
const workflow = await WorkflowRepository.getById({ id: input.id });
const isUserAuthorized = await isAuthorized(workflow, ctx.user.id, "workflow.read");
if (!isUserAuthorized) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
if (!workflow) {
return workflow;
}
// Add permissions to the workflow
const workflowWithPermissions = await addPermissionsToWorkflow(workflow, ctx.user.id);
return workflowWithPermissions;
};