Files
calendar/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts
T
3c1297aa72 fix: calcom trpc sessio circle dep (#19893)
* fix trpc session circle dep

* fixes trpc session cirlce dep

* fix relative imports

* fix more imports to use types and not trpc

* fix exports

* Fixed types

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-03-19 05:50:22 -03:00

41 lines
932 B
TypeScript

import { WebhookRepository } from "@calcom/lib/server/repository/webhook";
import type { Webhook } from "@calcom/prisma/client";
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
type GetByViewerOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
};
type WebhookGroup = {
teamId?: number | null;
profile: {
slug: string | null;
name: string | null;
image?: string;
};
metadata?: {
readOnly: boolean;
};
webhooks: Webhook[];
};
export type WebhooksByViewer = {
webhookGroups: WebhookGroup[];
profiles: {
readOnly?: boolean | undefined;
slug: string | null;
name: string | null;
image?: string | undefined;
teamId: number | null | undefined;
}[];
};
export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
return await WebhookRepository.getAllWebhooksByUserId({
userId: ctx.user.id,
userRole: ctx.user.role,
});
};