Skip to content

Commit bb9c4bb

Browse files
feat: Update HubSpot meetings to CANCELLED status instead of archiving on booking cancellation (calcom#24478)
* feat: Update HubSpot meetings to CANCELLED status instead of archiving When a booking is cancelled in Cal.com, preserve the meeting record in HubSpot by updating it to a CANCELLED status rather than archiving it. This maintains the meeting history for better tracking and reporting. Changes: - Renamed hubspotDeleteMeeting to hubspotCancelMeeting - Updated the method to set hs_meeting_outcome to CANCELLED - Changed from archive() to update() API call - Removed unused CustomPublicObjectInput interface Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: Remove return statement to match void return type in deleteEvent Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: Remove hs_timestamp from cancel meeting to keep it minimal Only update the meeting outcome status when cancelling, without modifying the timestamp field. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: Use correct HubSpot API value for canceled meetings Changed hs_meeting_outcome from "CANCELLED" to "CANCELED" to match HubSpot API specification. HubSpot uses lowercase American spelling "CANCELED" as the valid enum value for canceled meeting outcomes. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 02fdc13 commit bb9c4bb

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
2121
import refreshOAuthTokens from "../../_utils/oauth/refreshOAuthTokens";
2222
import type { HubspotToken } from "../api/callback";
2323

24-
interface CustomPublicObjectInput extends SimplePublicObjectInput {
25-
id?: string;
26-
}
27-
2824
export default class HubspotCalendarService implements CRM {
2925
private url = "";
3026
private integrationName = "";
@@ -117,8 +113,14 @@ export default class HubspotCalendarService implements CRM {
117113
return this.hubspotClient.crm.objects.meetings.basicApi.update(uid, simplePublicObjectInput);
118114
};
119115

120-
private hubspotDeleteMeeting = async (uid: string) => {
121-
return this.hubspotClient.crm.objects.meetings.basicApi.archive(uid);
116+
private hubspotCancelMeeting = async (uid: string) => {
117+
const simplePublicObjectInput: SimplePublicObjectInput = {
118+
properties: {
119+
hs_meeting_outcome: "CANCELED",
120+
},
121+
};
122+
123+
return this.hubspotClient.crm.objects.meetings.basicApi.update(uid, simplePublicObjectInput);
122124
};
123125

124126
private hubspotAuth = async (credential: CredentialPayload) => {
@@ -204,7 +206,6 @@ export default class HubspotCalendarService implements CRM {
204206
return await this.handleMeetingCreation(event, contacts);
205207
}
206208

207-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
208209
async updateEvent(uid: string, event: CalendarEvent): Promise<any> {
209210
const auth = await this.auth;
210211
await auth.getToken();
@@ -214,7 +215,7 @@ export default class HubspotCalendarService implements CRM {
214215
async deleteEvent(uid: string): Promise<void> {
215216
const auth = await this.auth;
216217
await auth.getToken();
217-
return await this.hubspotDeleteMeeting(uid);
218+
await this.hubspotCancelMeeting(uid);
218219
}
219220

220221
async getContacts({ emails }: { emails: string | string[] }): Promise<Contact[]> {

0 commit comments

Comments
 (0)