From ca7e27bd0609f4bc9ba1c9415dc381e61e31bee8 Mon Sep 17 00:00:00 2001 From: aalicic Date: Thu, 14 Jul 2022 01:10:47 +0200 Subject: [PATCH] fix: deleting logic if webhook subscriber method was called for another trigger event than booking_created --- .../vi/appointmentservice/controller/AskerController.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/vi/appointmentservice/controller/AskerController.java b/src/main/java/com/vi/appointmentservice/controller/AskerController.java index 67a5543..eb025bb 100644 --- a/src/main/java/com/vi/appointmentservice/controller/AskerController.java +++ b/src/main/java/com/vi/appointmentservice/controller/AskerController.java @@ -81,10 +81,9 @@ public ResponseEntity processBooking(CalcomWebhook calcomWebhook) { calcomBookingToAskerRepository.save(userAssociation); } else if(calcomWebhook.getTriggerEvent().equals("BOOKING_RESCHEDULED")){ String askerId = payload.getMetadata().getUser(); - CalcomBookingToAsker userAssociation = new CalcomBookingToAsker(bookingId, askerId); + CalcomBookingToAsker userAssociation = new CalcomBookingToAsker(Long.valueOf(payload.getBookingId()), askerId); calcomBookingToAskerRepository.save(userAssociation); - bookingId = payload.getMetadata().getBookingId(); - calcomBookingToAskerRepository.deleteByCalcomBookingId(bookingId); + calcomBookingToAskerRepository.deleteByCalcomBookingId(payload.getMetadata().getBookingId()); } else { //TODO: change this. we need to get booking id based on uuid or save it also in the relational // entity