File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import { SENDER_NAME } from "@calcom/lib/constants";
2424import { enrichUserWithDelegationCredentialsIncludeServiceAccountKey } from "@calcom/lib/delegationCredential/server" ;
2525import { getEventName } from "@calcom/lib/event" ;
2626import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server" ;
27+ import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService" ;
2728import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj" ;
2829import logger from "@calcom/lib/logger" ;
2930import { getTranslation } from "@calcom/lib/server/i18n" ;
@@ -181,6 +182,12 @@ export const roundRobinManualReassignment = async ({
181182 userPrimaryEmail : newUser . email ,
182183 reassignReason,
183184 reassignById : reassignedById ,
185+ idempotencyKey : IdempotencyKeyService . generate ( {
186+ startTime : booking . startTime ,
187+ endTime : booking . endTime ,
188+ userId : newUser . id ,
189+ reassignedById,
190+ } ) ,
184191 } ,
185192 select : bookingSelect ,
186193 } ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import {
2121 enrichUserWithDelegationCredentialsIncludeServiceAccountKey ,
2222} from "@calcom/lib/delegationCredential/server" ;
2323import { getEventName } from "@calcom/lib/event" ;
24+ import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server" ;
25+ import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService" ;
2426import { isPrismaObjOrUndefined } from "@calcom/lib/isPrismaObj" ;
2527import logger from "@calcom/lib/logger" ;
2628import { getLuckyUser } from "@calcom/lib/server/getLuckyUser" ;
@@ -238,6 +240,12 @@ export const roundRobinReassignment = async ({
238240 userId : reassignedRRHost . id ,
239241 userPrimaryEmail : reassignedRRHost . email ,
240242 title : newBookingTitle ,
243+ idempotencyKey : IdempotencyKeyService . generate ( {
244+ startTime : booking . startTime ,
245+ endTime : booking . endTime ,
246+ userId : reassignedRRHost . id ,
247+ reassignedById,
248+ } ) ,
241249 } ,
242250 select : bookingSelect ,
243251 } ) ;
Original file line number Diff line number Diff line change 1+ import { v5 as uuidv5 } from "uuid" ;
2+
3+ export class IdempotencyKeyService {
4+ static generate ( {
5+ startTime,
6+ endTime,
7+ userId,
8+ reassignedById,
9+ } : {
10+ startTime : Date | string ;
11+ endTime : Date | string ;
12+ userId ?: number ;
13+ reassignedById ?: number | null ;
14+ } ) {
15+ return uuidv5 (
16+ `${ startTime . valueOf ( ) } .${ endTime . valueOf ( ) } .${ userId } ${ reassignedById ? `.${ reassignedById } ` : "" } ` ,
17+ uuidv5 . URL
18+ ) ;
19+ }
20+ }
Original file line number Diff line number Diff line change 11import { Prisma } from "@prisma/client" ;
2- import { v5 as uuidv5 } from "uuid" ;
32
3+ import { IdempotencyKeyService } from "@calcom/lib/idempotencyKey/idempotencyKeyService" ;
44import { BookingStatus } from "@calcom/prisma/enums" ;
55
66export function bookingIdempotencyKeyExtension ( ) {
@@ -9,12 +9,12 @@ export function bookingIdempotencyKeyExtension() {
99 booking : {
1010 async create ( { args, query } ) {
1111 if ( args . data . status === BookingStatus . ACCEPTED ) {
12- const idempotencyKey = uuidv5 (
13- ` ${ args . data . startTime . valueOf ( ) } . ${ args . data . endTime . valueOf ( ) } . ${
14- args . data ?. user ?. connect ?. id
15- } ${ args . data ?. reassignById ? `. ${ args . data . reassignById } ` : "" } ` ,
16- uuidv5 . URL
17- ) ;
12+ const idempotencyKey = IdempotencyKeyService . generate ( {
13+ startTime : args . data . startTime ,
14+ endTime : args . data . endTime ,
15+ userId : args . data . user ?. connect ?. id ,
16+ reassignedById : args . data . reassignById ,
17+ } ) ;
1818 args . data . idempotencyKey = idempotencyKey ;
1919 }
2020 return query ( args ) ;
You can’t perform that action at this time.
0 commit comments