Files
cal.diy/packages/trpc/server/routers/loggedInViewer/getDownloadLinkOfCalVideoRecordings.handler.ts
T
1eeb91a793 perf: lazy load tRPC routes (#8167)
* experiment: cold start perf

* fix: update failing test

* chore: add database indexes

* chore: use json protocol and add query batching back

* Update [status].tsx

* Update [trpc].ts

* Delete getSlimSession.ts

* Update createContext.ts

* remove trpc caller

* correctly import Prisma

* lazy ethRouter

* replace crypto with md5

* import fixes

* public event endpoint refactor

* Update yarn.lock

* Update yarn.lock

* Using yarn.lock from main

---------

Co-authored-by: Omar López <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
Co-authored-by: Efraín Rochín <[email protected]>
Co-authored-by: Keith Williams <[email protected]>
2023-04-25 19:39:47 -03:00

39 lines
1.1 KiB
TypeScript

/// <reference types="@calcom/types/next-auth" />
import { getDownloadLinkOfCalVideoByRecordingId } from "@calcom/core/videoClient";
import { IS_SELF_HOSTED } from "@calcom/lib/constants";
import { TRPCError } from "@trpc/server";
import type { CreateInnerContextOptions } from "../../createContext";
import type { TGetDownloadLinkOfCalVideoRecordingsInputSchema } from "./getDownloadLinkOfCalVideoRecordings.schema";
type GetDownloadLinkOfCalVideoRecordingsHandlerOptions = {
ctx: CreateInnerContextOptions;
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",
});
}
};