Files
calendar/packages/trpc/server/routers/loggedInViewer/getDownloadLinkOfCalVideoRecordings.handler.ts
T
Keith WilliamsandGitHub 7180eb067a refactor: Move @calcom/core to @calcom/lib (#19655)
* refactor: Move @calcom/core to @calcom/lib

* Merging imports

* Clean up

* Ignoreing type error for now
2025-03-02 23:02:35 -03:00

39 lines
1.1 KiB
TypeScript

/// <reference types="@calcom/types/next-auth" />
import { IS_SELF_HOSTED } from "@calcom/lib/constants";
import { getDownloadLinkOfCalVideoByRecordingId } from "@calcom/lib/videoClient";
import { TRPCError } from "@trpc/server";
import type { WithSession } from "../../createContext";
import type { TGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
type GetDownloadLinkOfCalVideoRecordingsHandlerOptions = {
ctx: WithSession;
input: TGetDownloadLinkOfCalVideoRecordingsInputSchema;
};
export const getDownloadLinkOfCalVideoRecordingsHandler = async ({
input,
ctx,
}: GetDownloadLinkOfCalVideoRecordingsHandlerOptions) => {
const { recordingId } = input;
const { session } = ctx;
const isDownloadAllowed = IS_SELF_HOSTED || session?.user?.belongsToActiveTeam;
if (!isDownloadAllowed) {
throw new TRPCError({
code: "FORBIDDEN",
});
}
try {
const res = await getDownloadLinkOfCalVideoByRecordingId(recordingId);
return res;
} catch (err) {
throw new TRPCError({
code: "BAD_REQUEST",
});
}
};