2813 create message channel data model (#2952)
* create model * finished model * modidied visibility type to select * changed back to TEXT * handle instead of email * handle instead of email * handle instead of email * modified according to comment
This commit is contained in:
@ -36,7 +36,7 @@ export class GoogleGmailAuthController {
|
|||||||
await this.tokenService.verifyTransientToken(transientToken);
|
await this.tokenService.verifyTransientToken(transientToken);
|
||||||
|
|
||||||
this.googleGmailService.saveConnectedAccount({
|
this.googleGmailService.saveConnectedAccount({
|
||||||
email,
|
handle: email,
|
||||||
workspaceMemberId: workspaceMemberId,
|
workspaceMemberId: workspaceMemberId,
|
||||||
workspaceId: workspaceId,
|
workspaceId: workspaceId,
|
||||||
provider: 'gmail',
|
provider: 'gmail',
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import { ArgsType, Field } from '@nestjs/graphql';
|
import { ArgsType, Field } from '@nestjs/graphql';
|
||||||
|
|
||||||
import { IsEmail, IsNotEmpty, IsString } from 'class-validator';
|
import { IsNotEmpty, IsString } from 'class-validator';
|
||||||
|
|
||||||
@ArgsType()
|
@ArgsType()
|
||||||
export class SaveConnectedAccountInput {
|
export class SaveConnectedAccountInput {
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@IsEmail()
|
@IsString()
|
||||||
email: string;
|
handle: string;
|
||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export class GoogleGmailService {
|
|||||||
saveConnectedAccountInput: SaveConnectedAccountInput,
|
saveConnectedAccountInput: SaveConnectedAccountInput,
|
||||||
) {
|
) {
|
||||||
const {
|
const {
|
||||||
email,
|
handle,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
provider,
|
provider,
|
||||||
accessToken,
|
accessToken,
|
||||||
@ -33,8 +33,8 @@ export class GoogleGmailService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const connectedAccount = await workspaceDataSource?.query(
|
const connectedAccount = await workspaceDataSource?.query(
|
||||||
`SELECT * FROM ${dataSourceMetadata.schema}."connectedAccount" WHERE "email" = $1 AND "provider" = $2 AND "accountOwnerId" = $3`,
|
`SELECT * FROM ${dataSourceMetadata.schema}."connectedAccount" WHERE "handle" = $1 AND "provider" = $2 AND "accountOwnerId" = $3`,
|
||||||
[email, provider, workspaceMemberId],
|
[handle, provider, workspaceMemberId],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (connectedAccount.length > 0) {
|
if (connectedAccount.length > 0) {
|
||||||
@ -44,8 +44,8 @@ export class GoogleGmailService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await workspaceDataSource?.query(
|
await workspaceDataSource?.query(
|
||||||
`INSERT INTO ${dataSourceMetadata.schema}."connectedAccount" ("email", "provider", "accessToken", "refreshToken", "accountOwnerId") VALUES ($1, $2, $3, $4, $5)`,
|
`INSERT INTO ${dataSourceMetadata.schema}."connectedAccount" ("handle", "provider", "accessToken", "refreshToken", "accountOwnerId") VALUES ($1, $2, $3, $4, $5)`,
|
||||||
[email, provider, accessToken, refreshToken, workspaceMemberId],
|
[handle, provider, accessToken, refreshToken, workspaceMemberId],
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import {
|
|||||||
ObjectMetadata,
|
ObjectMetadata,
|
||||||
IsSystem,
|
IsSystem,
|
||||||
FieldMetadata,
|
FieldMetadata,
|
||||||
IsNullable,
|
|
||||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||||
import { ActivityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/activity.object-metadata';
|
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';
|
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
||||||
|
|||||||
@ -1,10 +1,14 @@
|
|||||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||||
|
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||||
import {
|
import {
|
||||||
ObjectMetadata,
|
ObjectMetadata,
|
||||||
IsSystem,
|
IsSystem,
|
||||||
FieldMetadata,
|
FieldMetadata,
|
||||||
|
IsNullable,
|
||||||
|
RelationMetadata,
|
||||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||||
import { BaseObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/base.object-metadata';
|
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 { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';
|
import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/workspace-member.object-metadata';
|
||||||
|
|
||||||
@ObjectMetadata({
|
@ObjectMetadata({
|
||||||
@ -18,11 +22,11 @@ import { WorkspaceMemberObjectMetadata } from 'src/workspace/workspace-sync-meta
|
|||||||
export class ConnectedAccountObjectMetadata extends BaseObjectMetadata {
|
export class ConnectedAccountObjectMetadata extends BaseObjectMetadata {
|
||||||
@FieldMetadata({
|
@FieldMetadata({
|
||||||
type: FieldMetadataType.TEXT,
|
type: FieldMetadataType.TEXT,
|
||||||
label: 'email',
|
label: 'handle',
|
||||||
description: 'The account email',
|
description: 'The account handle (email, username, phone number, etc.)',
|
||||||
icon: 'IconMail',
|
icon: 'IconMail',
|
||||||
})
|
})
|
||||||
email: string;
|
handle: string;
|
||||||
|
|
||||||
@FieldMetadata({
|
@FieldMetadata({
|
||||||
type: FieldMetadataType.TEXT,
|
type: FieldMetadataType.TEXT,
|
||||||
@ -34,7 +38,7 @@ export class ConnectedAccountObjectMetadata extends BaseObjectMetadata {
|
|||||||
|
|
||||||
@FieldMetadata({
|
@FieldMetadata({
|
||||||
type: FieldMetadataType.TEXT,
|
type: FieldMetadataType.TEXT,
|
||||||
label: 'accessToken',
|
label: 'Access Token',
|
||||||
description: 'Messaging provider access token',
|
description: 'Messaging provider access token',
|
||||||
icon: 'IconKey',
|
icon: 'IconKey',
|
||||||
})
|
})
|
||||||
@ -42,7 +46,7 @@ export class ConnectedAccountObjectMetadata extends BaseObjectMetadata {
|
|||||||
|
|
||||||
@FieldMetadata({
|
@FieldMetadata({
|
||||||
type: FieldMetadataType.TEXT,
|
type: FieldMetadataType.TEXT,
|
||||||
label: 'refreshToken',
|
label: 'Refresh Token',
|
||||||
description: 'Messaging provider refresh token',
|
description: 'Messaging provider refresh token',
|
||||||
icon: 'IconKey',
|
icon: 'IconKey',
|
||||||
})
|
})
|
||||||
@ -56,4 +60,17 @@ export class ConnectedAccountObjectMetadata extends BaseObjectMetadata {
|
|||||||
joinColumn: 'accountOwnerId',
|
joinColumn: 'accountOwnerId',
|
||||||
})
|
})
|
||||||
accountOwner: WorkspaceMemberObjectMetadata;
|
accountOwner: WorkspaceMemberObjectMetadata;
|
||||||
|
|
||||||
|
@FieldMetadata({
|
||||||
|
type: FieldMetadataType.RELATION,
|
||||||
|
label: 'Message Channel',
|
||||||
|
description: 'Message Channel',
|
||||||
|
icon: 'IconMessage',
|
||||||
|
})
|
||||||
|
@RelationMetadata({
|
||||||
|
type: RelationMetadataType.ONE_TO_MANY,
|
||||||
|
objectName: 'messageChannel',
|
||||||
|
})
|
||||||
|
@IsNullable()
|
||||||
|
messageChannels: MessageChannelObjectMetadata[];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { CommentObjectMetadata } from 'src/workspace/workspace-sync-metadata/sta
|
|||||||
import { CompanyObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/company.object-metadata';
|
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 { 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 { FavoriteObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/favorite.object-metadata';
|
||||||
|
import { MessageChannelObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/message-channel.object-metadata';
|
||||||
import { OpportunityObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/opportunity.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 { 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';
|
import { PipelineStepObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/pipeline-step.object-metadata';
|
||||||
@ -34,4 +35,5 @@ export const standardObjectMetadata = [
|
|||||||
ViewObjectMetadata,
|
ViewObjectMetadata,
|
||||||
WebhookObjectMetadata,
|
WebhookObjectMetadata,
|
||||||
WorkspaceMemberObjectMetadata,
|
WorkspaceMemberObjectMetadata,
|
||||||
|
MessageChannelObjectMetadata,
|
||||||
];
|
];
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
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';
|
||||||
|
import { ConnectedAccountObjectMetadata } from 'src/workspace/workspace-sync-metadata/standard-objects/connected-account.object-metadata';
|
||||||
|
|
||||||
|
@ObjectMetadata({
|
||||||
|
namePlural: 'messageChannels',
|
||||||
|
labelSingular: 'Message Channel',
|
||||||
|
labelPlural: 'Message Channels',
|
||||||
|
description: 'Message Channels',
|
||||||
|
icon: 'IconMessage',
|
||||||
|
})
|
||||||
|
@IsSystem()
|
||||||
|
export class MessageChannelObjectMetadata extends BaseObjectMetadata {
|
||||||
|
@FieldMetadata({
|
||||||
|
// This will be a type select later
|
||||||
|
type: FieldMetadataType.TEXT,
|
||||||
|
label: 'Visibility',
|
||||||
|
description: 'Visibility',
|
||||||
|
icon: 'IconEyeglass',
|
||||||
|
defaultValue: { value: 'metadata' },
|
||||||
|
})
|
||||||
|
visibility: string;
|
||||||
|
|
||||||
|
@FieldMetadata({
|
||||||
|
type: FieldMetadataType.TEXT,
|
||||||
|
label: 'Handle',
|
||||||
|
description: 'Handle',
|
||||||
|
icon: 'IconAt',
|
||||||
|
})
|
||||||
|
handle: string;
|
||||||
|
|
||||||
|
@FieldMetadata({
|
||||||
|
type: FieldMetadataType.RELATION,
|
||||||
|
label: 'Connected Account',
|
||||||
|
description: 'Connected Account',
|
||||||
|
icon: 'IconUserCircle',
|
||||||
|
joinColumn: 'connectedAccountId',
|
||||||
|
})
|
||||||
|
connectedAccount: ConnectedAccountObjectMetadata;
|
||||||
|
|
||||||
|
@FieldMetadata({
|
||||||
|
type: FieldMetadataType.TEXT,
|
||||||
|
label: 'Type',
|
||||||
|
description: 'Type',
|
||||||
|
icon: 'IconMessage',
|
||||||
|
})
|
||||||
|
@IsNullable()
|
||||||
|
type: string;
|
||||||
|
}
|
||||||
@ -2,7 +2,6 @@ import { CurrencyMetadata } from 'src/metadata/field-metadata/composite-types/cu
|
|||||||
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
import { FieldMetadataType } from 'src/metadata/field-metadata/field-metadata.entity';
|
||||||
import {
|
import {
|
||||||
ObjectMetadata,
|
ObjectMetadata,
|
||||||
IsSystem,
|
|
||||||
FieldMetadata,
|
FieldMetadata,
|
||||||
IsNullable,
|
IsNullable,
|
||||||
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
} from 'src/workspace/workspace-sync-metadata/decorators/metadata.decorator';
|
||||||
|
|||||||
Reference in New Issue
Block a user