File tree 2 files changed +11
-4
lines changed
packages/twenty-server/src/modules/mail-sender
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -9,4 +9,5 @@ export class MailSenderException extends CustomException {
9
9
10
10
export enum MailSenderExceptionCode {
11
11
PROVIDER_NOT_SUPPORTED = 'PROVIDER_NOT_SUPPORTED' ,
12
+ CONNECTED_ACCOUNT_NOT_FOUND = 'CONNECTED_ACCOUNT_NOT_FOUND' ,
12
13
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
21
21
} from 'src/modules/mail-sender/exceptions/mail-sender.exception' ;
22
22
import { GmailClientProvider } from 'src/modules/messaging/message-import-manager/drivers/gmail/providers/gmail-client.provider' ;
23
23
import { TwentyORMGlobalManager } from 'src/engine/twenty-orm/twenty-orm-global.manager' ;
24
+ import { isDefined } from 'src/utils/is-defined' ;
24
25
25
26
@Injectable ( )
26
27
export class SendEmailWorkflowAction {
@@ -48,12 +49,17 @@ export class SendEmailWorkflowAction {
48
49
workspaceId ,
49
50
'connectedAccount' ,
50
51
) ;
51
- const connectedAccount = await connectedAccountRepository . findOneOrFail ( {
52
- where : {
53
- id : step . settings . connectedAccountId ,
54
- } ,
52
+ const connectedAccount = await connectedAccountRepository . findOneBy ( {
53
+ id : step . settings . connectedAccountId ,
55
54
} ) ;
56
55
56
+ if ( ! isDefined ( connectedAccount ) ) {
57
+ throw new MailSenderException (
58
+ `Connected Account '${ step . settings . connectedAccountId } ' not found` ,
59
+ MailSenderExceptionCode . CONNECTED_ACCOUNT_NOT_FOUND ,
60
+ ) ;
61
+ }
62
+
57
63
switch ( connectedAccount . provider ) {
58
64
case 'google' :
59
65
return await this . gmailClientProvider . getGmailClient ( connectedAccount ) ;
You can’t perform that action at this time.
0 commit comments