Skip to content

Commit

Permalink
5483 modify messagechannel syncstatus (twentyhq#5484)
Browse files Browse the repository at this point in the history
- Closes twentyhq#5483
- Fix seeds
- Add default value to syncSubStatus
  • Loading branch information
bosiraphael committed May 21, 2024
1 parent 66a23a8 commit e47101e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const seedConnectedAccount = async (
refreshToken: 'exampleRefreshToken',
accessToken: 'exampleAccessToken',
provider: 'google',
handle: 'incoming',
handle: 'tim@apple.dev',
},
{
id: DEV_SEED_CONNECTED_ACCOUNT_IDS.JONY,
Expand All @@ -53,7 +53,7 @@ export const seedConnectedAccount = async (
refreshToken: 'exampleRefreshToken',
accessToken: 'exampleAccessToken',
provider: 'google',
handle: 'incoming',
handle: 'jony.ive@apple.dev',
},
{
id: DEV_SEED_CONNECTED_ACCOUNT_IDS.PHIL,
Expand All @@ -65,7 +65,7 @@ export const seedConnectedAccount = async (
refreshToken: 'exampleRefreshToken',
accessToken: 'exampleAccessToken',
provider: 'google',
handle: 'incoming',
handle: 'phil.schiler@apple.dev',
},
])
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const seedMessageChannelMessageAssociation = async (
messageThreadId: DEV_SEED_MESSAGE_THREAD_IDS.MESSAGE_THREAD_1,
messageExternalId: null,
messageId: DEV_SEED_MESSAGE_IDS.MESSAGE_1,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM_INCOMING,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM,
},
{
id: DEV_SEED_MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_IDS.MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_2,
Expand All @@ -52,7 +52,7 @@ export const seedMessageChannelMessageAssociation = async (
messageThreadId: DEV_SEED_MESSAGE_THREAD_IDS.MESSAGE_THREAD_2,
messageExternalId: null,
messageId: DEV_SEED_MESSAGE_IDS.MESSAGE_2,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM_INCOMING,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM,
},
{
id: DEV_SEED_MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_IDS.MESSAGE_CHANNEL_MESSAGE_ASSOCIATION_3,
Expand All @@ -63,7 +63,7 @@ export const seedMessageChannelMessageAssociation = async (
messageThreadId: DEV_SEED_MESSAGE_THREAD_IDS.MESSAGE_THREAD_1,
messageExternalId: null,
messageId: DEV_SEED_MESSAGE_IDS.MESSAGE_3,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM_INCOMING,
messageChannelId: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM,
},
])
.execute();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { EntityManager } from 'typeorm';

import { DEV_SEED_CONNECTED_ACCOUNT_IDS } from 'src/database/typeorm-seeds/workspace/connected-account';
import { MessageChannelSyncSubStatus } from 'src/modules/messaging/standard-objects/message-channel.workspace-entity';

const tableName = 'messageChannel';

export const DEV_SEED_MESSAGE_CHANNEL_IDS = {
TIM_INCOMING: '20202020-9b80-4c2c-a597-383db48de1d6',
TIM_OUTGOING: '20202020-09ed-4eb9-8b23-62aa4fd81d83',
JONY_INCOMING: '20202020-5ffe-4b32-814a-983d5e4911cd',
JONY_OUTGOING: '20202020-9dad-4329-8180-62647a2d7510',
PHIL_INCOMING: '20202020-e2f1-49b5-85d2-5d3a3386990c',
PHIL_OUTGOING: '20202020-fdff-438f-9132-7d5f216dfc4d',
TIM: '20202020-9b80-4c2c-a597-383db48de1d6',
JONY: '20202020-5ffe-4b32-814a-983d5e4911cd',
PHIL: '20202020-e2f1-49b5-85d2-5d3a3386990c',
};

export const seedMessageChannel = async (
Expand All @@ -30,74 +28,48 @@ export const seedMessageChannel = async (
'connectedAccountId',
'handle',
'visibility',
'syncSubStatus',
])
.orIgnore()
.values([
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM_INCOMING,
id: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.TIM,
handle: 'outgoing',
handle: 'tim@apple.dev',
visibility: 'share_everything',
syncSubStatus:
MessageChannelSyncSubStatus.FULL_MESSAGES_LIST_FETCH_PENDING,
},
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.TIM_OUTGOING,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.TIM,
handle: 'incoming',
visibility: 'share_everything',
},
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.JONY_INCOMING,
id: DEV_SEED_MESSAGE_CHANNEL_IDS.JONY,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.JONY,
handle: 'outgoing',
visibility: 'share_everything',
},
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.JONY_OUTGOING,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.JONY,
handle: 'incoming',
visibility: 'share_everything',
},
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.PHIL_INCOMING,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.PHIL,
handle: 'outgoing',
handle: 'jony.ive@apple.dev',
visibility: 'share_everything',
syncSubStatus:
MessageChannelSyncSubStatus.FULL_MESSAGES_LIST_FETCH_PENDING,
},
{
id: DEV_SEED_MESSAGE_CHANNEL_IDS.PHIL_OUTGOING,
id: DEV_SEED_MESSAGE_CHANNEL_IDS.PHIL,
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: null,
isContactAutoCreationEnabled: true,
type: 'email',
connectedAccountId: DEV_SEED_CONNECTED_ACCOUNT_IDS.PHIL,
handle: 'incoming',
handle: 'phil.schiler@apple.dev',
visibility: 'share_everything',
syncSubStatus:
MessageChannelSyncSubStatus.FULL_MESSAGES_LIST_FETCH_PENDING,
},
])
.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ import { WorkspaceIsNullable } from 'src/engine/twenty-orm/decorators/workspace-
import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator';

export enum MessageChannelSyncStatus {
// TO BE DEPRECATED
PENDING = 'PENDING',
ONGOING = 'ONGOING',
SUCCEEDED = 'SUCCEEDED',
FAILED = 'FAILED',

// NEW STATUSES
NOT_SYNCED = 'NOT_SYNCED',
ONGOING = 'ONGOING',
COMPLETED = 'COMPLETED',
FAILED_INSUFFICIENT_PERMISSIONS = 'FAILED_INSUFFICIENT_PERMISSIONS',
FAILED_UNKNOWN = 'FAILED_UNKNOWN',
}

export enum MessageChannelSyncSubStatus {
Expand Down Expand Up @@ -163,18 +170,13 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
description: 'Sync status',
icon: 'IconStatusChange',
options: [
// TO BE DEPRECATED: PENDING, SUCCEEDED, FAILED
{
value: MessageChannelSyncStatus.PENDING,
label: 'Pending',
position: 0,
color: 'blue',
},
{
value: MessageChannelSyncStatus.ONGOING,
label: 'Ongoing',
position: 1,
color: 'yellow',
},
{
value: MessageChannelSyncStatus.SUCCEEDED,
label: 'Succeeded',
Expand All @@ -187,6 +189,37 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
position: 3,
color: 'red',
},
// NEW STATUSES
{
value: MessageChannelSyncStatus.ONGOING,
label: 'Ongoing',
position: 1,
color: 'yellow',
},
{
value: MessageChannelSyncStatus.NOT_SYNCED,
label: 'Not Synced',
position: 4,
color: 'blue',
},
{
value: MessageChannelSyncStatus.COMPLETED,
label: 'Completed',
position: 5,
color: 'green',
},
{
value: MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS,
label: 'Failed Insufficient Permissions',
position: 6,
color: 'red',
},
{
value: MessageChannelSyncStatus.FAILED_UNKNOWN,
label: 'Failed Unknown',
position: 7,
color: 'red',
},
],
})
@WorkspaceIsNullable()
Expand Down Expand Up @@ -230,6 +263,7 @@ export class MessageChannelWorkspaceEntity extends BaseWorkspaceEntity {
color: 'orange',
},
],
defaultValue: `'${MessageChannelSyncSubStatus.FULL_MESSAGES_LIST_FETCH_PENDING}'`,
})
syncSubStatus: MessageChannelSyncSubStatus;

Expand Down

0 comments on commit e47101e

Please sign in to comment.