Fix send email error when empty connected account (#10005)
- Fix send email error when empty connected account - Add a global util to valid uuid - Add an util to check if object is workflow related
This commit is contained in:
@ -1,15 +1,12 @@
|
||||
import { isValidUuid } from 'twenty-shared';
|
||||
|
||||
import {
|
||||
WorkspaceQueryRunnerException,
|
||||
WorkspaceQueryRunnerExceptionCode,
|
||||
} from 'src/engine/api/graphql/workspace-query-runner/workspace-query-runner.exception';
|
||||
|
||||
export const assertIsValidUuid = (value: string) => {
|
||||
const isValid =
|
||||
/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.test(
|
||||
value,
|
||||
);
|
||||
|
||||
if (!isValid) {
|
||||
if (!isValidUuid(value)) {
|
||||
throw new WorkspaceQueryRunnerException(
|
||||
`Value "${value}" is not a valid UUID`,
|
||||
WorkspaceQueryRunnerExceptionCode.INVALID_QUERY_INPUT,
|
||||
|
||||
@ -11,4 +11,5 @@ export enum SendEmailActionExceptionCode {
|
||||
PROVIDER_NOT_SUPPORTED = 'PROVIDER_NOT_SUPPORTED',
|
||||
CONNECTED_ACCOUNT_NOT_FOUND = 'CONNECTED_ACCOUNT_NOT_FOUND',
|
||||
INVALID_EMAIL = 'INVALID_EMAIL',
|
||||
INVALID_CONNECTED_ACCOUNT_ID = 'INVALID_CONNECTED_ACCOUNT_ID',
|
||||
}
|
||||
|
||||
@ -2,8 +2,8 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
|
||||
import DOMPurify from 'dompurify';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import { isDefined, isValidUuid } from 'twenty-shared';
|
||||
import { z } from 'zod';
|
||||
import { isDefined } from 'twenty-shared';
|
||||
|
||||
import { WorkflowAction } from 'src/modules/workflow/workflow-executor/interfaces/workflow-action.interface';
|
||||
|
||||
@ -36,6 +36,13 @@ export class SendEmailWorkflowAction implements WorkflowAction {
|
||||
) {}
|
||||
|
||||
private async getEmailClient(connectedAccountId: string) {
|
||||
if (!isValidUuid(connectedAccountId)) {
|
||||
throw new SendEmailActionException(
|
||||
`Connected Account ID is not a valid UUID`,
|
||||
SendEmailActionExceptionCode.INVALID_CONNECTED_ACCOUNT_ID,
|
||||
);
|
||||
}
|
||||
|
||||
const { workspaceId } = this.scopedWorkspaceContextFactory.create();
|
||||
|
||||
if (!workspaceId) {
|
||||
|
||||
Reference in New Issue
Block a user