* add webhook version schema * version the code * update version from numeric to date val * migration * update schema and build factory * update string * move version picker * tooltip instead of infobadge * -- * fix type * -- * fix type * fix type * -- * fix messed up merge * improvements to payloadfactory * extract version off of DB and instead keep it in IWebhookRepository * fix webhookform * fix type safety and routing ambiguity * scalable with easier factory extensions and base definition * fix types * -- * -- * clean up prisma/client type imports * fix * type fix * type fix * cleanup * add tests and registry changes * unintended file inclusion * type-fix * select in repo * -- * explicit return type * -- * fix type * fixes * feedback 1 * feedback 2 * use enum instead of string * fixes
30 lines
937 B
TypeScript
30 lines
937 B
TypeScript
import type { WebhookGroup } from "@calcom/features/webhooks/lib/dto/types";
|
|
import { WebhookRepository } from "@calcom/features/webhooks/lib/repository/WebhookRepository";
|
|
import type { TrpcSessionUser } from "@calcom/trpc/server/types";
|
|
|
|
type GetByViewerOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
};
|
|
|
|
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): Promise<WebhooksByViewer> => {
|
|
// Use the singleton instance to avoid creating new instances repeatedly
|
|
const webhookRepository = WebhookRepository.getInstance();
|
|
return await webhookRepository.getFilteredWebhooksForUser({
|
|
userId: ctx.user.id,
|
|
userRole: ctx.user.role,
|
|
});
|
|
};
|