Files
calendar/packages/trpc/server/routers/viewer/webhook/getByViewer.handler.ts
T
2089ad40ea fix: Wrong avatars shown in webhooks page (#19386)
* fix: Wrong avatars shown in webhooks page

* Fix teams showing wrong avatar

* Fix type error

* Remove unused function arguments

---------

Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com>
2025-02-24 08:02:57 +00:00

41 lines
931 B
TypeScript

import { WebhookRepository } from "@calcom/lib/server/repository/webhook";
import type { Webhook } from "@calcom/prisma/client";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
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,
});
};