fix: Ensure event type duplication respects private link setting (#13438)

* fix: Ensure event type duplication respects private link setting

* chode refactor

* Fix: Handler throwing error on creating duplicate of a collective event having private-link switched on.

---------

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
Somay ChauhanandKeith Williams authored and GitHub committed 2024-02-07 09:30:28 +01:00
1 parent d2b4760e3a
commit a0451e34c1
4 files changed
+25 -18

No files matched your search

@@ -1,5 +1,6 @@
import { Prisma } from "@prisma/client";
import { generateHashedLink } from "@calcom/lib/generateHashedLink";
import { EventTypeRepository } from "@calcom/lib/server/repository/eventType";
import { prisma } from "@calcom/prisma";
@@ -40,6 +41,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
team: true,
workflows: true,
webhooks: true,
hashedLink: true,
destinationCalendar: true,
},
});
@@ -73,6 +75,7 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
durationLimits,
metadata,
workflows,
hashedLink,
destinationCalendar,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
id: _id,
@@ -119,6 +122,17 @@ export const duplicateHandler = async ({ ctx, input }: DuplicateOptions) => {
});
}
if (hashedLink) {
await prisma.hashedLink.create({
data: {
link: generateHashedLink(users[0]?.id ?? newEventType.teamId),
eventType: {
connect: { id: newEventType.id },
},
},
});
}
if (workflows.length > 0) {
const relationCreateData = workflows.map((workflow) => {
return { eventTypeId: newEventType.id, workflowId: workflow.workflowId };