@@ -64,7 +64,10 @@ export class SESService implements Handler {
6464 const providersSet = new Set ( providerObjects ) ;
6565 this . sesConfig = null
6666 for ( const element of providersSet ) {
67- if ( element [ 'dest' ] === "ses" ) {
67+ if ( ( element [ 'dest' ] === "ses" ) && ( element [ 'configId' ] != 0 ) ) {
68+ await this . getConfigById ( element [ 'configId' ] , providersSet , event , sesTemplate , setting , destinationMap , configsMap )
69+ break
70+ } else if ( element [ 'dest' ] === "ses" ) {
6871 await this . getDefaultConfig ( providersSet , event , sesTemplate , setting , destinationMap , configsMap )
6972 break
7073 }
@@ -102,6 +105,36 @@ export class SESService implements Handler {
102105 }
103106 }
104107
108+ private async getConfigById ( id , providersSet , event : Event , sesTemplate : NotificationTemplates , setting : NotificationSettings , emailMap : Map < string , boolean > , configsMap : Map < string , boolean > ) {
109+ try {
110+ const config = await this . sesConfigRepository . findBySESConfigId ( id )
111+ this . sesConfig = {
112+ region : config [ 'region' ] ,
113+ access_key : config [ 'access_key' ] ,
114+ secret_access_key : config [ 'secret_access_key' ] ,
115+ from_email : config [ 'from_email' ]
116+ }
117+ if ( this . sesConfig && this . sesConfig . from_email ) {
118+ for ( const p of providersSet ) {
119+ if ( p [ 'dest' ] == "ses" ) {
120+ let recipient = p [ 'recipient' ]
121+ let configKey = '' ;
122+ if ( recipient ) {
123+ configKey = p [ 'dest' ] + '-' + recipient
124+ }
125+ if ( ! configsMap . get ( configKey ) ) {
126+ await this . processNotification ( recipient , event , sesTemplate , setting , p , emailMap )
127+ configsMap . set ( configKey , true )
128+ }
129+ }
130+ } ;
131+ }
132+ } catch ( error ) {
133+ this . logger . error ( 'getDefaultConfig' , error )
134+ throw new CustomError ( "Unable to send SES notification" , 500 ) ;
135+ }
136+ }
137+
105138 private async preparePayloadAndSend ( event : Event , sesTemplate : NotificationTemplates , setting : NotificationSettings , p : string ) {
106139 let sdk : NotifmeSdk = new NotifmeSdk ( {
107140 channels : {
0 commit comments