Skip to content

Commit 089a39f

Browse files
feat: add integration options for API v2 update booking location endpoint (calcom#26363)
* init: improvements for update location endpoint * chore: init function to update calendar event * fix: bad imports * chore: update calendar event when updating location * chore: update platform libraries * fix: update calendar event * chore: update platform libraries * chore: cleanup * feat: add logic for video conferecing integrations * chore: update platform libraries * feat: add sms and email notifications * chore: update e2e tests * chore: update openapi spec * chore: implement cubic feedback * chore: update openapi spec * fix: add Jest mock for Daily.co video adapter in e2e test Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * fix: mock createMeeting directly to bypass database check in e2e test Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * chore: implement PR feedback * chore: implement feedback * fix: mock throttler guard to prevent rate limiting in e2e tests Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * fix: merge conflicts * chore: update platform libraries * chore: implement feedback part 1 * chore: implement feedback part 2 * chore: remove unnecessary type casting * chore: implement cubic feedback * chore: implement devin feedback * chore: implement PR feedback * fix: type error * chore: update openapi spec * test: add mocks and tests for Google Meet and Microsoft Teams integration location updates Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * refactor: simplify service code - extract shared helpers, remove duplication Co-Authored-By: rajiv@cal.com <sahalrajiv6900@gmail.com> * feat: implement fixtures for bookings references --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 4291a59 commit 089a39f

18 files changed

Lines changed: 1340 additions & 52 deletions

apps/api/v2/src/ee/bookings/2024-08-13/bookings.module.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { BookingReferencesRepository_2024_08_13 } from "@/ee/bookings/2024-08-13
88
import { BookingsRepository_2024_08_13 } from "@/ee/bookings/2024-08-13/repositories/bookings.repository";
99
import { BookingAttendeesService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-attendees.service";
1010
import { BookingGuestsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-guests.service";
11+
import { BookingLocationCalendarSyncService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-location-calendar-sync.service";
12+
import { BookingLocationCredentialService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-location-credential.service";
13+
import { BookingLocationIntegrationService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-location-integration.service";
1114
import { BookingLocationService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-location.service";
15+
import { BookingVideoService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-video.service";
1216
import { BookingReferencesService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-references.service";
1317
import { BookingsService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/bookings.service";
1418
import { CalVideoOutputService } from "@/ee/bookings/2024-08-13/services/cal-video.output.service";
@@ -108,7 +112,11 @@ import { UsersModule } from "@/modules/users/users.module";
108112
CalVideoService,
109113
CalVideoOutputService,
110114
BookingPbacGuard,
115+
BookingLocationCalendarSyncService_2024_08_13,
116+
BookingLocationCredentialService_2024_08_13,
117+
BookingLocationIntegrationService_2024_08_13,
111118
BookingLocationService_2024_08_13,
119+
BookingVideoService_2024_08_13,
112120
PrismaFeaturesRepository,
113121
],
114122
controllers: [

apps/api/v2/src/ee/bookings/2024-08-13/controllers/booking-location.controller.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1+
import { BOOKING_WRITE, SUCCESS_STATUS } from "@calcom/platform-constants";
2+
import {
3+
UpdateBookingInputAttendeeAddressLocation_2024_08_13,
4+
UpdateBookingInputAttendeeDefinedLocation_2024_08_13,
5+
UpdateBookingInputAttendeePhoneLocation_2024_08_13,
6+
UpdateBookingInputLinkLocation_2024_08_13,
7+
UpdateBookingInputPhoneLocation_2024_08_13,
8+
UpdateBookingLocationInput_2024_08_13,
9+
UpdateInputAddressLocation_2024_08_13,
10+
} from "@calcom/platform-types";
11+
import { Body, Controller, HttpCode, HttpStatus, Param, Patch, UseGuards } from "@nestjs/common";
12+
import { ApiExtraModels, ApiHeader, ApiOperation, ApiTags as DocsTags } from "@nestjs/swagger";
113
import { BookingUidGuard } from "@/ee/bookings/2024-08-13/guards/booking-uid.guard";
214
import { UpdateBookingLocationOutput_2024_08_13 } from "@/ee/bookings/2024-08-13/outputs/update-location.output";
315
import { BookingLocationService_2024_08_13 } from "@/ee/bookings/2024-08-13/services/booking-location.service";
4-
import { VERSION_2024_08_13_VALUE, VERSION_2024_08_13 } from "@/lib/api-versions";
16+
import { VERSION_2024_08_13, VERSION_2024_08_13_VALUE } from "@/lib/api-versions";
517
import { API_KEY_OR_ACCESS_TOKEN_HEADER } from "@/lib/docs/headers";
18+
import { Throttle } from "@/lib/endpoint-throttler-decorator";
619
import { GetUser } from "@/modules/auth/decorators/get-user/get-user.decorator";
720
import { Permissions } from "@/modules/auth/decorators/permissions/permissions.decorator";
821
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
922
import { PermissionsGuard } from "@/modules/auth/guards/permissions/permissions.guard";
1023
import { ApiAuthGuardUser } from "@/modules/auth/strategies/api-auth/api-auth.strategy";
11-
import { Controller, Patch, Logger, Body, UseGuards, Param, HttpCode, HttpStatus } from "@nestjs/common";
12-
import { ApiExtraModels, ApiOperation, ApiTags as DocsTags, ApiHeader } from "@nestjs/swagger";
13-
14-
import { BOOKING_WRITE, SUCCESS_STATUS } from "@calcom/platform-constants";
15-
import {
16-
UpdateBookingLocationInput_2024_08_13,
17-
UpdateInputAddressLocation_2024_08_13,
18-
UpdateBookingInputAttendeeAddressLocation_2024_08_13,
19-
UpdateBookingInputAttendeeDefinedLocation_2024_08_13,
20-
UpdateBookingInputAttendeePhoneLocation_2024_08_13,
21-
UpdateBookingInputLinkLocation_2024_08_13,
22-
UpdateBookingInputPhoneLocation_2024_08_13,
23-
} from "@calcom/platform-types";
2424

2525
@Controller({
2626
path: "/v2/bookings/:bookingUid/location",
@@ -43,20 +43,23 @@ import {
4343
required: true,
4444
})
4545
export class BookingLocationController_2024_08_13 {
46-
private readonly logger = new Logger("BookingLocationController_2024_08_13");
47-
4846
constructor(private readonly bookingLocationService: BookingLocationService_2024_08_13) {}
4947

5048
@Patch("/")
5149
@HttpCode(HttpStatus.OK)
50+
@Throttle({ name: "booking_location_update", limit: 5, ttl: 60000, blockDuration: 60000 })
5251
@Permissions([BOOKING_WRITE])
5352
@UseGuards(ApiAuthGuard, BookingUidGuard)
5453
@ApiHeader(API_KEY_OR_ACCESS_TOKEN_HEADER)
5554
@ApiOperation({
5655
summary: "Update booking location for an existing booking",
57-
description: `**Current Limitation:** Updating a booking location will update the location in Cal.com, but the corresponding Calendar event will not be updated automatically. The old location will persist in the Calendar event. This is a known limitation that will be addressed in a future update.
58-
59-
<Note>The cal-api-version header is required for this endpoint. Without it, the request will fail with a 404 error.</Note>`,
56+
description: `Updates the location for an existing booking.
57+
58+
**Integration Fallback Behavior:**
59+
- **Google Meet**: Requires Google Calendar to be connected. If the booking has no Google Calendar event, it will automatically fall back to Cal Video.
60+
- **MS Teams**: If Office 365 Calendar is connected, generates the meeting link via calendar. Otherwise, uses the MS Teams video integration directly.
61+
62+
<Note>The cal-api-version header is required for this endpoint. Without it, the request will fail with a 404 error.</Note>`,
6063
})
6164
async updateBookingLocation(
6265
@Param("bookingUid") bookingUid: string,

0 commit comments

Comments
 (0)