fix: Zapier subscriber url shown in webhooks (#12702)

Co-authored-by: Carina Wollendorfer <30310907+CarinaWolli@users.noreply.github.com>
This commit is contained in:
Riddhesh Mahajan 2023-12-15 21:39:59 +05:30 committed by GitHub
parent 9dfa596e3e
commit fcb443a8eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,6 +39,15 @@ export type WebhooksByViewer = {
}[]; }[];
}; };
const filterWebhooks = (webhook: Webhook) => {
const appIds = [
"zapier",
// Add more if needed
];
return !appIds.some((appId: string) => webhook.appId == appId);
};
export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => { export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
const user = await prisma.user.findUnique({ const user = await prisma.user.findUnique({
where: { where: {
@ -80,7 +89,8 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" }); throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
} }
const userWebhooks = user.webhooks; let userWebhooks = user.webhooks;
userWebhooks = userWebhooks.filter(filterWebhooks);
let webhookGroups: WebhookGroup[] = []; let webhookGroups: WebhookGroup[] = [];
const bookerUrl = await getBookerUrl(user); const bookerUrl = await getBookerUrl(user);
@ -132,7 +142,7 @@ export const getByViewerHandler = async ({ ctx }: GetByViewerOptions) => {
: MembershipRole.MEMBER : MembershipRole.MEMBER
: MembershipRole.MEMBER), : MembershipRole.MEMBER),
}, },
webhooks: membership.team.webhooks, webhooks: membership.team.webhooks.filter(filterWebhooks),
}; };
}); });