diff --git a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts index 402fc905f9ee..30c07bac18a2 100644 --- a/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts +++ b/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts @@ -67,6 +67,7 @@ export const CALENDAR_CHANNEL_STANDARD_FIELD_IDS = { handle: '20202020-1d08-420a-9aa7-22e0f298232d', visibility: '20202020-1b07-4796-9f01-d626bab7ca4d', isContactAutoCreationEnabled: '20202020-50fb-404b-ba28-369911a3793a', + contactAutoCreationPolicy: '20202020-b55d-447d-b4df-226319058775', isSyncEnabled: '20202020-fe19-4818-8854-21f7b1b43395', syncCursor: '20202020-bac2-4852-a5cb-7a7898992b70', calendarChannelEventAssociations: '20202020-afb0-4a9f-979f-2d5087d71d09', @@ -205,6 +206,9 @@ export const MESSAGE_CHANNEL_STANDARD_FIELD_IDS = { connectedAccount: '20202020-49a2-44a4-b470-282c0440d15d', type: '20202020-ae95-42d9-a3f1-797a2ea22122', isContactAutoCreationEnabled: '20202020-fabd-4f14-b7c6-3310f6d132c6', + contactAutoCreationPolicy: '20202020-fc0e-4ba6-b259-a66ca89cfa38', + excludeNonProfessionalEmails: '20202020-1df5-445d-b4f3-2413ad178431', + excludeGroupEmails: '20202020-45a0-4be4-9164-5820a6a109fb', messageChannelMessageAssociations: '20202020-49b8-4766-88fd-75f1e21b3d5f', isSyncEnabled: '20202020-d9a6-48e9-990b-b97fdf22e8dd', syncCursor: '20202020-79d1-41cf-b738-bcf5ed61e256', diff --git a/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts b/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts index d886865dd34b..cbade9375a0a 100644 --- a/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts +++ b/packages/twenty-server/src/modules/calendar/standard-objects/calendar-channel.workspace-entity.ts @@ -40,6 +40,13 @@ export enum CalendarChannelSyncStage { FAILED = 'FAILED', } +export enum CalendarChannelContactAutoCreationPolicy { + AS_PARTICIPANT_AND_ORGANIZER = 'AS_PARTICIPANT_AND_ORGANIZER', + AS_PARTICIPANT = 'AS_PARTICIPANT', + AS_ORGANIZER = 'AS_ORGANIZER', + NONE = 'NONE', +} + @WorkspaceEntity({ standardId: STANDARD_OBJECT_IDS.calendarChannel, namePlural: 'calendarChannels', @@ -186,6 +193,44 @@ export class CalendarChannelWorkspaceEntity extends BaseWorkspaceEntity { }) isContactAutoCreationEnabled: boolean; + @WorkspaceField({ + standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.contactAutoCreationPolicy, + type: FieldMetadataType.SELECT, + label: 'Contact auto creation policy', + description: + 'Automatically create records for people you participated with in an event.', + icon: 'IconUserCircle', + options: [ + { + value: + CalendarChannelContactAutoCreationPolicy.AS_PARTICIPANT_AND_ORGANIZER, + label: 'As Participant and Organizer', + color: 'green', + position: 0, + }, + { + value: CalendarChannelContactAutoCreationPolicy.AS_PARTICIPANT, + label: 'As Participant', + color: 'orange', + position: 1, + }, + { + value: CalendarChannelContactAutoCreationPolicy.AS_ORGANIZER, + label: 'As Organizer', + color: 'blue', + position: 2, + }, + { + value: CalendarChannelContactAutoCreationPolicy.NONE, + label: 'None', + color: 'red', + position: 3, + }, + ], + defaultValue: `'${CalendarChannelContactAutoCreationPolicy.AS_PARTICIPANT_AND_ORGANIZER}'`, + }) + contactAutoCreationPolicy: CalendarChannelContactAutoCreationPolicy; + @WorkspaceField({ standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.isSyncEnabled, type: FieldMetadataType.BOOLEAN, diff --git a/packages/twenty-server/src/modules/messaging/common/standard-objects/message-channel.workspace-entity.ts b/packages/twenty-server/src/modules/messaging/common/standard-objects/message-channel.workspace-entity.ts index 160912737e3a..682e367e4c0d 100644 --- a/packages/twenty-server/src/modules/messaging/common/standard-objects/message-channel.workspace-entity.ts +++ b/packages/twenty-server/src/modules/messaging/common/standard-objects/message-channel.workspace-entity.ts @@ -52,6 +52,12 @@ export enum MessageChannelType { SMS = 'sms', } +export enum MessageChannelContactAutoCreationPolicy { + SENT_AND_RECEIVED = 'SENT_AND_RECEIVED', + SENT = 'SENT', + NONE = 'NONE', +} + @WorkspaceEntity({ standardId: STANDARD_OBJECT_IDS.messageChannel, namePlural: 'messageChannels', @@ -126,6 +132,7 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity { }) type: string; + // TODO: Deprecate this field and migrate data to contactAutoCreationFor @WorkspaceField({ standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.isContactAutoCreationEnabled, type: FieldMetadataType.BOOLEAN, @@ -136,6 +143,57 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity { }) isContactAutoCreationEnabled: boolean; + @WorkspaceField({ + standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.contactAutoCreationPolicy, + type: FieldMetadataType.SELECT, + label: 'Contact auto creation policy', + description: + 'Automatically create People records when receiving or sending emails', + icon: 'IconUserCircle', + options: [ + { + value: MessageChannelContactAutoCreationPolicy.SENT_AND_RECEIVED, + label: 'Sent and Received', + position: 0, + color: 'green', + }, + { + value: MessageChannelContactAutoCreationPolicy.SENT, + label: 'Sent', + position: 1, + color: 'blue', + }, + { + value: MessageChannelContactAutoCreationPolicy.NONE, + label: 'None', + position: 2, + color: 'red', + }, + ], + defaultValue: `'${MessageChannelContactAutoCreationPolicy.SENT}'`, + }) + contactAutoCreationPolicy: MessageChannelContactAutoCreationPolicy; + + @WorkspaceField({ + standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.excludeNonProfessionalEmails, + type: FieldMetadataType.BOOLEAN, + label: 'Exclude non professional emails', + description: 'Exclude non professional emails', + icon: 'IconBriefcase', + defaultValue: true, + }) + excludeNonProfessionalEmails: boolean; + + @WorkspaceField({ + standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.excludeGroupEmails, + type: FieldMetadataType.BOOLEAN, + label: 'Exclude group emails', + description: 'Exclude group emails', + icon: 'IconUsersGroup', + defaultValue: true, + }) + excludeGroupEmails: boolean; + @WorkspaceField({ standardId: MESSAGE_CHANNEL_STANDARD_FIELD_IDS.isSyncEnabled, type: FieldMetadataType.BOOLEAN,