From 880fe151c079b38ce12d8828fcb8537004a22df8 Mon Sep 17 00:00:00 2001 From: Lauris Skraucis Date: Thu, 17 Apr 2025 17:50:16 +0200 Subject: [PATCH] fix: v2 automatic round robin reassign error message (#20755) --- .../2024-08-13/services/bookings.service.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts index 021623b666..7a2d375d28 100644 --- a/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts +++ b/apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts @@ -646,13 +646,24 @@ export class BookingsService_2024_08_13 { const profile = this.usersService.getUserMainProfile(requestUser); - await roundRobinReassignment({ - bookingId: booking.id, - orgId: profile?.organizationId || null, - emailsEnabled, - platformClientParams, - reassignedById: requestUser.id, - }); + try { + await roundRobinReassignment({ + bookingId: booking.id, + orgId: profile?.organizationId || null, + emailsEnabled, + platformClientParams, + reassignedById: requestUser.id, + }); + } catch (error) { + if (error instanceof Error) { + if (error.message === "no_available_users_found_error") { + throw new BadRequestException( + "Can't reassign the booking because no other host is available at that time." + ); + } + } + throw error; + } const reassigned = await this.bookingsRepository.getByUidWithUser(bookingUid); if (!reassigned) {