Update calendar when new attendees are added to bookings w/ seats (#3257)
Co-authored-by: Omar López <[email protected]> Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
2 files changed
+24
-4
No files matched your search
@@ -234,6 +234,7 @@ async function handler(req: NextApiRequest) {
|
||||
!eventTypeId && !!eventTypeSlug ? getDefaultEvent(eventTypeSlug) : await getEventTypesFromDB(eventTypeId);
|
||||
if (!eventType) throw new HttpError({ statusCode: 404, message: "eventType.notFound" });
|
||||
|
||||
let user: User | null = null;
|
||||
let users = !eventTypeId
|
||||
? await prisma.user.findMany({
|
||||
where: {
|
||||
@@ -362,8 +363,19 @@ async function handler(req: NextApiRequest) {
|
||||
where: {
|
||||
uid: reqBody.bookingUid,
|
||||
},
|
||||
include: {
|
||||
select: {
|
||||
id: true,
|
||||
attendees: true,
|
||||
references: {
|
||||
select: {
|
||||
type: true,
|
||||
uid: true,
|
||||
meetingId: true,
|
||||
meetingPassword: true,
|
||||
meetingUrl: true,
|
||||
externalCalendarId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!booking) throw new HttpError({ statusCode: 404, message: "Booking not found" });
|
||||
@@ -401,6 +413,11 @@ async function handler(req: NextApiRequest) {
|
||||
|
||||
await sendScheduledSeatsEmails(evt, invitee[0], newSeat);
|
||||
|
||||
user = users[0];
|
||||
const credentials = await refreshCredentials(user.credentials);
|
||||
const eventManager = new EventManager({ ...user, credentials });
|
||||
await eventManager.updateCalendarAttendees(evt, booking);
|
||||
|
||||
req.statusCode = 201;
|
||||
return booking;
|
||||
}
|
||||
@@ -577,7 +594,6 @@ async function handler(req: NextApiRequest) {
|
||||
|
||||
let results: EventResult<AdditionalInformation>[] = [];
|
||||
let referencesToCreate: PartialReference[] = [];
|
||||
let user: User | null = null;
|
||||
|
||||
/** Let's start checking for availability */
|
||||
for (const currentUser of users) {
|
||||
@@ -683,7 +699,7 @@ async function handler(req: NextApiRequest) {
|
||||
|
||||
if (originalRescheduledBooking?.uid) {
|
||||
// Use EventManager to conditionally use all needed integrations.
|
||||
const updateManager = await eventManager.update(
|
||||
const updateManager = await eventManager.reschedule(
|
||||
evt,
|
||||
originalRescheduledBooking.uid,
|
||||
booking?.id,
|
||||
|
||||
Reference in new issue
Block a user