From 01c9307465753be7c4ee41a02821e577c130306d Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 12:09:32 +0100 Subject: [PATCH 1/8] create message thread --- .../message-thread.object-metadata.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts new file mode 100644 index 000000000000..22ef29af8d75 --- /dev/null +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts @@ -0,0 +1,48 @@ +import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { + ObjectMetadata, + IsSystem, + FieldMetadata, + IsNullable, +} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; +import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; + +@ObjectMetadata({ + namePlural: 'messageThreads', + labelSingular: 'Message Thread', + labelPlural: 'Message Threads', + description: 'Message Thread', + icon: 'IconMessage', +}) +@IsSystem() +export class MessageThreadObjectMetadata extends BaseObjectMetadata { + @FieldMetadata({ + // will be an array + type: FieldMetadataType.TEXT, + label: 'External Ids', + description: 'Thread ids from the messaging provider', + icon: 'IconMessage', + }) + @IsNullable() + externalIds: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Subject', + description: 'Subject', + icon: 'IconMessage', + }) + @IsNullable() + subject: string; + + @FieldMetadata({ + // This will be a type select later: default, subject, share_everything + type: FieldMetadataType.TEXT, + label: 'Visibility', + description: 'Visibility', + icon: 'IconEyeglass', + defaultValue: { value: 'default' }, + }) + @IsNullable() + visibility: string; +} From 01aaa9bd0e4b19a64ac16956fe44d184645c854f Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 12:30:18 +0100 Subject: [PATCH 2/8] link message threads and message --- .../comment.object-metadata.ts | 1 - .../message-thread.object-metadata.ts | 16 +++++ .../message.object-metadata.ts | 66 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata.ts index 06df486bad24..4326b454c4d3 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/comment.object-metadata.ts @@ -3,7 +3,6 @@ import { ObjectMetadata, IsSystem, FieldMetadata, - IsNullable, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.object-metadata'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts index 22ef29af8d75..c36d4f546390 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts @@ -1,11 +1,14 @@ import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity'; import { ObjectMetadata, IsSystem, FieldMetadata, IsNullable, + RelationMetadata, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; +import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; @ObjectMetadata({ namePlural: 'messageThreads', @@ -45,4 +48,17 @@ export class MessageThreadObjectMetadata extends BaseObjectMetadata { }) @IsNullable() visibility: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Messages', + description: 'Messages from the thread.', + icon: 'IconFileImport', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'message', + }) + @IsNullable() + messages: MessageObjectMetadata[]; } diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts new file mode 100644 index 000000000000..ac49919406f9 --- /dev/null +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -0,0 +1,66 @@ +import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { + ObjectMetadata, + IsSystem, + FieldMetadata, + IsNullable, +} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; +import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; + +@ObjectMetadata({ + namePlural: 'message', + labelSingular: 'Message', + labelPlural: 'Messages', + description: 'Message', + icon: 'IconMessage', +}) +@IsSystem() +export class MessageObjectMetadata extends BaseObjectMetadata { + @FieldMetadata({ + // will be an array + type: FieldMetadataType.TEXT, + label: 'External Ids', + description: 'Message ids from the messaging provider', + icon: 'IconHash', + }) + @IsNullable() + externalIds: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Thread Id', + description: 'Message Thread Id', + icon: 'IconHash', + joinColumn: 'messageThreadId', + }) + @IsNullable() + messageThread: string; + + @FieldMetadata({ + // will be a select later: incoming, outgoing + type: FieldMetadataType.TEXT, + label: 'Direction', + description: 'Direction', + icon: 'IconDirection', + defaultValue: { value: 'incoming' }, + }) + direction: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Subject', + description: 'Subject', + icon: 'IconMessage', + }) + @IsNullable() + subject: string; + + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Body', + description: 'Body', + icon: 'IconMessage', + }) + @IsNullable() + body: string; +} From afe57dd13aa26b12f2539c8e039f24f5e8fedb37 Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 12:36:30 +0100 Subject: [PATCH 3/8] add ton index.ts --- .../workspace-sync-metadata/standard-objects/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts index 56ab4f5b3212..a6d287fa0099 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/index.ts @@ -6,6 +6,8 @@ import { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/sta import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata'; import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata'; import { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata'; +import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; +import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.object-metadata'; import { PersonObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/person.object-metadata'; import { PipelineStepObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/pipeline-step.object-metadata'; @@ -34,4 +36,6 @@ export const standardObjectMetadata = [ ViewObjectMetadata, WebhookObjectMetadata, WorkspaceMemberObjectMetadata, + MessageThreadObjectMetadata, + MessageObjectMetadata, ]; From 9f5de7c9da108fc8747fd02d167ad6353ca30ffe Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 15:31:34 +0100 Subject: [PATCH 4/8] finished models --- .../message-channel.object-metadata.ts | 17 +++++++++++++++++ .../message-thread.object-metadata.ts | 13 ++++++++++++- .../standard-objects/message.object-metadata.ts | 3 ++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts index 513d6a60215c..64d7d132a66d 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts @@ -1,12 +1,15 @@ import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity'; +import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity'; import { ObjectMetadata, IsSystem, FieldMetadata, IsNullable, + RelationMetadata, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata'; +import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; @ObjectMetadata({ namePlural: 'messageChannels', @@ -45,6 +48,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata { connectedAccount: ConnectedAccountObjectMetadata; @FieldMetadata({ + // This will be a type select later : email, sms, chat type: FieldMetadataType.TEXT, label: 'Type', description: 'Type', @@ -52,4 +56,17 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata { }) @IsNullable() type: string; + + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Threads', + description: 'Threads from the channel.', + icon: 'IconFileImport', + }) + @RelationMetadata({ + type: RelationMetadataType.ONE_TO_MANY, + objectName: 'messageThread', + }) + @IsNullable() + messageThreads: MessageThreadObjectMetadata[]; } diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts index c36d4f546390..451c5db4a2bf 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts @@ -8,6 +8,7 @@ import { RelationMetadata, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; +import { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata'; import { MessageObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata'; @ObjectMetadata({ @@ -38,6 +39,16 @@ export class MessageThreadObjectMetadata extends BaseObjectMetadata { @IsNullable() subject: string; + @FieldMetadata({ + type: FieldMetadataType.RELATION, + label: 'Message Channel Id', + description: 'Message Channel Id', + icon: 'IconHash', + joinColumn: 'messageChannelId', + }) + @IsNullable() + messageChannel: MessageChannelObjectMetadata; + @FieldMetadata({ // This will be a type select later: default, subject, share_everything type: FieldMetadataType.TEXT, @@ -53,7 +64,7 @@ export class MessageThreadObjectMetadata extends BaseObjectMetadata { type: FieldMetadataType.RELATION, label: 'Messages', description: 'Messages from the thread.', - icon: 'IconFileImport', + icon: 'IconMessage', }) @RelationMetadata({ type: RelationMetadataType.ONE_TO_MANY, diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts index ac49919406f9..0d0cfbeab9c0 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -6,6 +6,7 @@ import { IsNullable, } from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator'; import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata'; +import { MessageThreadObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata'; @ObjectMetadata({ namePlural: 'message', @@ -34,7 +35,7 @@ export class MessageObjectMetadata extends BaseObjectMetadata { joinColumn: 'messageThreadId', }) @IsNullable() - messageThread: string; + messageThread: MessageThreadObjectMetadata; @FieldMetadata({ // will be a select later: incoming, outgoing From b12ce992ca43df43cadfbf93cd658cb94da30db4 Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 15:33:39 +0100 Subject: [PATCH 5/8] header mail id --- .../standard-objects/message.object-metadata.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts index 0d0cfbeab9c0..d441544fa35f 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -27,6 +27,15 @@ export class MessageObjectMetadata extends BaseObjectMetadata { @IsNullable() externalIds: string; + @FieldMetadata({ + type: FieldMetadataType.TEXT, + label: 'Header mail Id', + description: 'Mail id from the mail header', + icon: 'IconHash', + }) + @IsNullable() + headerMailId: string; + @FieldMetadata({ type: FieldMetadataType.RELATION, label: 'Message Thread Id', From 017c8e2b00e51f1dc3936f19175ff47450a35a3b Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 15:37:09 +0100 Subject: [PATCH 6/8] update icon --- .../standard-objects/message-channel.object-metadata.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts index 64d7d132a66d..c8947c17cfc0 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata.ts @@ -61,7 +61,7 @@ export class MessageChannelObjectMetadata extends BaseObjectMetadata { type: FieldMetadataType.RELATION, label: 'Message Threads', description: 'Threads from the channel.', - icon: 'IconFileImport', + icon: 'IconMessage', }) @RelationMetadata({ type: RelationMetadataType.ONE_TO_MANY, From 59c43d7cbfdfa20fd5ed3b78e7b3fe75c70bae74 Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 15:55:44 +0100 Subject: [PATCH 7/8] modifications --- .../standard-objects/message.object-metadata.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts index d441544fa35f..a98983214cda 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message.object-metadata.ts @@ -20,21 +20,21 @@ export class MessageObjectMetadata extends BaseObjectMetadata { @FieldMetadata({ // will be an array type: FieldMetadataType.TEXT, - label: 'External Ids', - description: 'Message ids from the messaging provider', + label: 'External Id', + description: 'Message id from the messaging provider', icon: 'IconHash', }) @IsNullable() - externalIds: string; + externalId: string; @FieldMetadata({ type: FieldMetadataType.TEXT, - label: 'Header mail Id', - description: 'Mail id from the mail header', + label: 'Header message Id', + description: 'Message id from the message header', icon: 'IconHash', }) @IsNullable() - headerMailId: string; + headerMessageId: string; @FieldMetadata({ type: FieldMetadataType.RELATION, From d4d8099a28f2f981cb5255fdb5766a6041fb97ea Mon Sep 17 00:00:00 2001 From: bosiraphael Date: Tue, 12 Dec 2023 15:59:24 +0100 Subject: [PATCH 8/8] update externalId --- .../standard-objects/message-thread.object-metadata.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts index 451c5db4a2bf..3e1c1edef9a1 100644 --- a/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts +++ b/packages/twenty-server/src/workspace/workspace-sync-metadata/standard-objects/message-thread.object-metadata.ts @@ -23,12 +23,12 @@ export class MessageThreadObjectMetadata extends BaseObjectMetadata { @FieldMetadata({ // will be an array type: FieldMetadataType.TEXT, - label: 'External Ids', - description: 'Thread ids from the messaging provider', + label: 'External Id', + description: 'Thread id from the messaging provider', icon: 'IconMessage', }) @IsNullable() - externalIds: string; + externalId: string; @FieldMetadata({ type: FieldMetadataType.TEXT,