* trpc procedures an middleware refactor * allow use sessionMiddleware without a req object * sync with the new tRPC structure * tRPC refactor on routing form app * import Prisma from @prisma/client * Lazy load apps from appstore * remove unrelated changes * Add types for PaymentService * type fixes * Merge branch 'main' into roae85/cal-1514-set-the-user-session-only-on-the * fix typo * remove console.log * remove explicit types from apstore object * linter fixes --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
39 lines
1.1 KiB
TypeScript
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 { 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",
|
|
});
|
|
}
|
|
};
|