Skip to content

Commit 9fcddbf

Browse files
anikdhabaldevin-ai-integration[bot]ThyMinimalDev
authored
refactor: calEventParser CalendarEvent ISP (calcom#25890)
* refactor: calEventParser CalendarEvent ISP * update * fix: complete CalEventParser ISP refactoring - update call sites and fix type errors - Update getUid call sites to pass only uid instead of whole CalendarEvent - Update getLocation call sites to pass narrow shape with videoCallData, additionalInformation, location, uid - Update narrow input shapes to accept null for location (matching CalendarEvent type) - Update recurringEvent type to accept RecurringEvent | null instead of boolean - Update videoCallData type to be more flexible ({ type?: string; url?: string }) - Fix ManageLink.tsx to pass recurringEvent directly instead of converting to boolean Co-Authored-By: anik@cal.com <adhabal2002@gmail.com> * test: update CalEventParser tests to use narrow input shapes - Update getPublicVideoCallUrl test to pass uid instead of calEvent - Update getVideoCallPassword tests to pass videoCallData instead of calEvent Co-Authored-By: anik@cal.com <adhabal2002@gmail.com> * few fix * fix type error --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
1 parent c42d602 commit 9fcddbf

17 files changed

Lines changed: 426 additions & 136 deletions

File tree

packages/app-store/feishucalendar/lib/CalendarService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,14 @@ class FeishuCalendarService implements Calendar {
392392
],
393393
};
394394
if (event.location) {
395-
feishuEvent.location = { name: getLocation(event) };
395+
feishuEvent.location = {
396+
name: getLocation({
397+
videoCallData: event.videoCallData,
398+
additionalInformation: event.additionalInformation,
399+
location: event.location,
400+
uid: event.uid,
401+
}),
402+
};
396403
}
397404
return feishuEvent;
398405
};

packages/app-store/googlecalendar/lib/CalendarService.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ class GoogleCalendarService implements Calendar {
189189
}
190190

191191
if (calEvent.location) {
192-
payload["location"] = getLocation(calEvent);
192+
payload["location"] = getLocation({
193+
videoCallData: calEvent.videoCallData,
194+
additionalInformation: calEvent.additionalInformation,
195+
location: calEvent.location,
196+
uid: calEvent.uid,
197+
});
193198
}
194199

195200
if (calEvent.recurringEvent) {
@@ -246,7 +251,12 @@ class GoogleCalendarService implements Calendar {
246251
calendarId: selectedCalendar,
247252
eventId: event.id || "",
248253
requestBody: {
249-
location: getLocation(calEvent),
254+
location: getLocation({
255+
videoCallData: calEvent.videoCallData,
256+
additionalInformation: calEvent.additionalInformation,
257+
location: calEvent.location,
258+
uid: calEvent.uid,
259+
}),
250260
description: calEvent.calendarDescription,
251261
},
252262
});
@@ -345,7 +355,12 @@ class GoogleCalendarService implements Calendar {
345355
};
346356

347357
if (event.location) {
348-
payload["location"] = getLocation(event);
358+
payload["location"] = getLocation({
359+
videoCallData: event.videoCallData,
360+
additionalInformation: event.additionalInformation,
361+
location: event.location,
362+
uid: event.uid,
363+
});
349364
}
350365

351366
if (event.conferenceData && event.location === MeetLocationType) {

packages/app-store/hubspot/lib/CrmService.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ class HubspotCalendarService implements CRM {
5555
private getHubspotMeetingBody = (event: CalendarEvent): string => {
5656
const userFields = getLabelValueMapFromResponses(event);
5757
const plainText = event?.description?.replace(/<\/?[^>]+(>|$)/g, "").replace(/_/g, " ");
58-
const location = getLocation(event);
58+
const location = getLocation({
59+
videoCallData: event.videoCallData,
60+
additionalInformation: event.additionalInformation,
61+
location: event.location,
62+
uid: event.uid,
63+
});
5964
const userFieldsHtml = Object.entries(userFields)
6065
.map(([key, value]) => {
6166
const formattedValue = typeof value === "boolean" ? (value ? "Yes" : "No") : value || "-";
@@ -283,7 +288,12 @@ class HubspotCalendarService implements CRM {
283288
hs_timestamp: Date.now().toString(),
284289
hs_meeting_title: event.title,
285290
hs_meeting_body: this.getHubspotMeetingBody(event),
286-
hs_meeting_location: getLocation(event),
291+
hs_meeting_location: getLocation({
292+
videoCallData: event.videoCallData,
293+
additionalInformation: event.additionalInformation,
294+
location: event.location,
295+
uid: event.uid,
296+
}),
287297
hs_meeting_start_time: new Date(event.startTime).toISOString(),
288298
hs_meeting_end_time: new Date(event.endTime).toISOString(),
289299
hs_meeting_outcome: "SCHEDULED",
@@ -323,7 +333,12 @@ class HubspotCalendarService implements CRM {
323333
hs_timestamp: Date.now().toString(),
324334
hs_meeting_title: event.title,
325335
hs_meeting_body: this.getHubspotMeetingBody(event),
326-
hs_meeting_location: getLocation(event),
336+
hs_meeting_location: getLocation({
337+
videoCallData: event.videoCallData,
338+
additionalInformation: event.additionalInformation,
339+
location: event.location,
340+
uid: event.uid,
341+
}),
327342
hs_meeting_start_time: new Date(event.startTime).toISOString(),
328343
hs_meeting_end_time: new Date(event.endTime).toISOString(),
329344
hs_meeting_outcome: "RESCHEDULED",

packages/app-store/larkcalendar/lib/CalendarService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,14 @@ class LarkCalendarService implements Calendar {
392392
],
393393
};
394394
if (event.location) {
395-
larkEvent.location = { name: getLocation(event) };
395+
larkEvent.location = {
396+
name: getLocation({
397+
videoCallData: event.videoCallData,
398+
additionalInformation: event.additionalInformation,
399+
location: event.location,
400+
uid: event.uid,
401+
}),
402+
};
396403
}
397404
return larkEvent;
398405
};

packages/app-store/pipedrive-crm/lib/CrmService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ class PipedriveCrmService implements CRM {
121121
startDateTime: event.startTime,
122122
endDateTime: event.endTime,
123123
description: this.getMeetingBody(event),
124-
location: getLocation(event),
124+
location: getLocation({
125+
videoCallData: event.videoCallData,
126+
additionalInformation: event.additionalInformation,
127+
location: event.location,
128+
uid: event.uid,
129+
}),
125130
associations: {
126131
contactId: String(contacts[0].id),
127132
},
@@ -147,7 +152,12 @@ class PipedriveCrmService implements CRM {
147152
startDateTime: event.startTime,
148153
endDateTime: event.endTime,
149154
description: this.getMeetingBody(event),
150-
location: getLocation(event),
155+
location: getLocation({
156+
videoCallData: event.videoCallData,
157+
additionalInformation: event.additionalInformation,
158+
location: event.location,
159+
uid: event.uid,
160+
}),
151161
};
152162
const headers = new Headers();
153163
headers.append("x-revert-api-token", this.revertApiKey);

packages/app-store/salesforce/lib/CrmService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,12 @@ class SalesforceCRMService implements CRM {
226226
EndDateTime: new Date(event.endTime).toISOString(),
227227
Subject: event.title,
228228
Description: this.getSalesforceEventBody(event),
229-
Location: getLocation(event),
229+
Location: getLocation({
230+
videoCallData: event.videoCallData,
231+
additionalInformation: event.additionalInformation,
232+
location: event.location,
233+
uid: event.uid,
234+
}),
230235
...options,
231236
...(event.recurringEvent && {
232237
IsRecurrence2: true,
@@ -334,7 +339,12 @@ class SalesforceCRMService implements CRM {
334339
EndDateTime: new Date(event.endTime).toISOString(),
335340
Subject: event.title,
336341
Description: this.getSalesforceEventBody(event),
337-
Location: getLocation(event),
342+
Location: getLocation({
343+
videoCallData: event.videoCallData,
344+
additionalInformation: event.additionalInformation,
345+
location: event.location,
346+
uid: event.uid,
347+
}),
338348
...(event.recurringEvent && {
339349
IsRecurrence2: true,
340350
Recurrence2PatternText: new RRule(event.recurringEvent).toString(),

packages/app-store/zoho-bigin/lib/CrmService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,12 @@ class BiginCrmService implements CRM {
189189
Start_DateTime: toISO8601String(new Date(event.startTime)),
190190
End_DateTime: toISO8601String(new Date(event.endTime)),
191191
Description: event.additionalNotes,
192-
Venue: getLocation(event),
192+
Venue: getLocation({
193+
videoCallData: event.videoCallData,
194+
additionalInformation: event.additionalInformation,
195+
location: event.location,
196+
uid: event.uid,
197+
}),
193198
Who_Id: contacts[0].id,
194199
};
195200

@@ -249,7 +254,12 @@ class BiginCrmService implements CRM {
249254
Start_DateTime: toISO8601String(new Date(event.startTime)),
250255
End_DateTime: toISO8601String(new Date(event.endTime)),
251256
Description: event.additionalNotes,
252-
Location: getLocation(event),
257+
Location: getLocation({
258+
videoCallData: event.videoCallData,
259+
additionalInformation: event.additionalInformation,
260+
location: event.location,
261+
uid: event.uid,
262+
}),
253263
};
254264

255265
return axios

packages/app-store/zohocalendar/lib/CalendarService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,14 @@ class ZohoCalendarService implements Calendar {
473473
action: "popup",
474474
},
475475
],
476-
location: event.location ? getLocation(event) : undefined,
476+
location: event.location
477+
? getLocation({
478+
videoCallData: event.videoCallData,
479+
additionalInformation: event.additionalInformation,
480+
location: event.location,
481+
uid: event.uid,
482+
})
483+
: undefined,
477484
};
478485

479486
return zohoEvent;

packages/app-store/zohocrm/lib/CrmService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ class ZohoCrmCrmService implements CRM {
134134
Start_DateTime: toISO8601String(new Date(event.startTime)),
135135
End_DateTime: toISO8601String(new Date(event.endTime)),
136136
Description: this.getMeetingBody(event),
137-
Venue: getLocation(event),
137+
Venue: getLocation({
138+
videoCallData: event.videoCallData,
139+
additionalInformation: event.additionalInformation,
140+
location: event.location,
141+
uid: event.uid,
142+
}),
138143
Who_Id: contacts[0].id, // Link the first attendee as the primary Who_Id
139144
};
140145

@@ -158,7 +163,12 @@ class ZohoCrmCrmService implements CRM {
158163
Start_DateTime: toISO8601String(new Date(event.startTime)),
159164
End_DateTime: toISO8601String(new Date(event.endTime)),
160165
Description: this.getMeetingBody(event),
161-
Venue: getLocation(event),
166+
Venue: getLocation({
167+
videoCallData: event.videoCallData,
168+
additionalInformation: event.additionalInformation,
169+
location: event.location,
170+
uid: event.uid,
171+
}),
162172
};
163173
return axios({
164174
method: "put",

packages/emails/src/components/ManageLink.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,30 @@ export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person })
55
// Only the original attendee can make changes to the event
66
// Guests cannot
77
const t = props.attendee.language.translate;
8-
const cancelLink = getCancelLink(props.calEvent, props.attendee);
8+
const cancelLink = getCancelLink(
9+
{
10+
platformClientId: props.calEvent.platformClientId,
11+
platformCancelUrl: props.calEvent.platformCancelUrl,
12+
type: props.calEvent.type,
13+
organizer: props.calEvent.organizer,
14+
recurringEvent: props.calEvent.recurringEvent,
15+
bookerUrl: props.calEvent.bookerUrl,
16+
uid: props.calEvent.uid,
17+
attendeeSeatId: props.calEvent.attendeeSeatId,
18+
team: props.calEvent.team,
19+
},
20+
props.attendee
21+
);
922
const rescheduleLink = getRescheduleLink({ calEvent: props.calEvent, attendee: props.attendee });
10-
const bookingLink = getBookingUrl(props.calEvent);
23+
const bookingLink = getBookingUrl({
24+
platformClientId: props.calEvent.platformClientId,
25+
platformBookingUrl: props.calEvent.platformBookingUrl,
26+
bookerUrl: props.calEvent.bookerUrl,
27+
type: props.calEvent.type,
28+
uid: props.calEvent.uid,
29+
organizer: props.calEvent.organizer,
30+
attendeeSeatId: props.calEvent.attendeeSeatId,
31+
});
1132

1233
const isOriginalAttendee = props.attendee.email === props.calEvent.attendees[0]?.email;
1334
const isOrganizer = props.calEvent.organizer.email === props.attendee.email;

0 commit comments

Comments
 (0)