@@ -310,22 +310,26 @@ getTeamJob.schema = Joi.object().keys({
310
310
311
311
/**
312
312
* Send email through a particular template
313
+ * @param {Object } currentUser the user who perform this operation
313
314
* @param {Object } data the email object
314
315
* @returns {undefined }
315
316
*/
316
- async function sendEmail ( data ) {
317
+ async function sendEmail ( currentUser , data ) {
317
318
const template = emailTemplates [ data . template ]
318
319
await helper . postEvent ( config . EMAIL_TOPIC , {
319
- subject : template . subjectTemplate ( data . data ) ,
320
- handle : data . data . userHandle ,
321
- message : template . messageTemplate ( data . data ) ,
320
+ data : {
321
+ handle : currentUser . handle ,
322
+ subject : template . subjectTemplate ( data . data ) ,
323
+ message : template . messageTemplate ( data . data ) ,
324
+ } ,
322
325
sendgrid_template_id : template . sendgridTemplateId ,
323
326
version : 'v3' ,
324
327
recipients : template . recipients
325
328
} )
326
329
}
327
330
328
331
sendEmail . schema = Joi . object ( ) . keys ( {
332
+ currentUser : Joi . object ( ) . required ( ) ,
329
333
data : Joi . object ( ) . keys ( {
330
334
template : Joi . string ( ) . valid ( ...Object . keys ( emailTemplates ) ) . required ( ) ,
331
335
data : Joi . object ( ) . required ( )
0 commit comments