File tree 3 files changed +7
-7
lines changed 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ workflows:
82
82
context : org-global
83
83
filters :
84
84
branches :
85
- only : ['dev']
85
+ only : ['dev', 'feature/decouple-sendgridtemplateid' ]
86
86
- " build-prod " :
87
87
context : org-global
88
88
filters :
Original file line number Diff line number Diff line change @@ -46,4 +46,6 @@ module.exports = {
46
46
47
47
API_CONTEXT_PATH : process . env . API_CONTEXT_PATH || '/v5/email' ,
48
48
49
+ PAYLOAD_SENDGRID_TEMPLATE_KEY : process . env . PAYLOAD_SENDGRID_TEMPLATE_KEY || 'sendgrid_template_id' ,
50
+
49
51
} ;
Original file line number Diff line number Diff line change @@ -22,20 +22,18 @@ emailServer.setConfig({ LOG_LEVEL: 'debug' });
22
22
// the message is JSON event message,
23
23
// the callback is function(error, templateId), where templateId is the used SendGrid template id
24
24
const handler = ( topic , message , callback ) => {
25
- const templateId = config . TEMPLATE_MAP [ topic ] ;
26
- if ( templateId === undefined ) {
25
+ let templateId = config . TEMPLATE_MAP [ topic ] ;
26
+ templateId = _ . get ( message , config . PAYLOAD_SENDGRID_TEMPLATE_KEY , templateId ) ;
27
+ if ( ! templateId ) {
27
28
return callback ( null , { success : false , error : `Template not found for topic ${ topic } ` } ) ;
28
29
}
29
30
30
- try {
31
31
service . sendEmail ( templateId , message ) . then ( ( ) => {
32
32
callback ( null , { success : true } ) ;
33
33
} ) . catch ( ( err ) => {
34
+ logger . error ( "Error occurred in sendgrid api calling:" , err ) ;
34
35
callback ( null , { success : false , error : err } ) ;
35
36
} ) ;
36
- } catch ( error ) {
37
- logger . error ( 'Unknown Error: ' , error ) ;
38
- }
39
37
40
38
} ;
41
39
You can’t perform that action at this time.
0 commit comments