Skip to content

The open alternative to Salesforce, designed for AI.

fix(server): skip callRecordings widget in calendar-event page sync when field is absent (#21967)

Charles Bochet2276e12c1249
diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command.ts
index 7d810a65b6c..2bc9ce77c5e 100644
--- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command.ts
+++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command.ts
@@ -61,12 +61,17 @@ const CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS = [
.widgets.fields.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
.widgets.participants.universalIdentifier,
- STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
- .widgets.callRecordings.universalIdentifier,
STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs
.timeline.widgets.timeline.universalIdentifier,
];
+const CALENDAR_EVENT_CALL_RECORDINGS_WIDGET_UNIVERSAL_IDENTIFIER =
+ STANDARD_PAGE_LAYOUT_UNIVERSAL_IDENTIFIERS.calendarEventRecordPage.tabs.home
+ .widgets.callRecordings.universalIdentifier;
+
+const CALENDAR_EVENT_CALL_RECORDINGS_FIELD_UNIVERSAL_IDENTIFIER =
+ STANDARD_OBJECTS.calendarEvent.fields.callRecordings.universalIdentifier;
+
@RegisteredWorkspaceCommand('2.15.0', 1800000002000)
@Command({
name: 'upgrade:2-15:sync-calendar-event-record-page',
@@ -96,6 +101,7 @@ export class SyncCalendarEventRecordPageCommand extends ActiveOrSuspendedWorkspa
const {
flatObjectMetadataMaps,
+ flatFieldMetadataMaps,
flatViewMaps,
flatViewFieldMaps,
flatViewFieldGroupMaps,
@@ -104,6 +110,7 @@ export class SyncCalendarEventRecordPageCommand extends ActiveOrSuspendedWorkspa
flatPageLayoutWidgetMaps,
} = await this.workspaceCacheService.getOrRecompute(workspaceId, [
'flatObjectMetadataMaps',
+ 'flatFieldMetadataMaps',
'flatViewMaps',
'flatViewFieldMaps',
'flatViewFieldGroupMaps',
@@ -125,6 +132,19 @@ export class SyncCalendarEventRecordPageCommand extends ActiveOrSuspendedWorkspa
return;
}
+ const hasCallRecordingsField = isDefined(
+ flatFieldMetadataMaps.byUniversalIdentifier[
+ CALENDAR_EVENT_CALL_RECORDINGS_FIELD_UNIVERSAL_IDENTIFIER
+ ],
+ );
+
+ const pageLayoutWidgetUniversalIdentifiers = hasCallRecordingsField
+ ? [
+ ...CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS,
+ CALENDAR_EVENT_CALL_RECORDINGS_WIDGET_UNIVERSAL_IDENTIFIER,
+ ]
+ : CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS;
+
const { allFlatEntityMaps: standardAllFlatEntityMaps } =
computeTwentyStandardApplicationAllFlatEntityMaps({
now: new Date().toISOString(),
@@ -169,8 +189,7 @@ export class SyncCalendarEventRecordPageCommand extends ActiveOrSuspendedWorkspa
standardFlatEntityMaps:
standardAllFlatEntityMaps.flatPageLayoutWidgetMaps,
existingFlatEntityMaps: flatPageLayoutWidgetMaps,
- universalIdentifiers:
- CALENDAR_EVENT_PAGE_LAYOUT_WIDGET_UNIVERSAL_IDENTIFIERS,
+ universalIdentifiers: pageLayoutWidgetUniversalIdentifiers,
});
const totalOperationCount =