@@ -220,7 +220,7 @@ async function getResourceRole (roleId, isCreated) {
220220 * @param {String } challengeId the challenge id
221221 * @param {Object } resource the resource to be created
222222 * @param {Boolean } isCreated the flag indicate it is create operation.
223- * @returns {Object } the resource entities and member information.
223+ * @returns {Promise< Object> } the resource entities and member information.
224224 */
225225async function init ( currentUser , challengeId , resource , isCreated ) {
226226 // Verify that the challenge exists
@@ -363,9 +363,10 @@ async function init (currentUser, challengeId, resource, isCreated) {
363363async function createResource ( currentUser , resource ) {
364364 try {
365365 const challengeId = resource . challengeId
366-
367366 const { memberId, handle, email, challenge, closeRegistration } = await init ( currentUser , challengeId , resource , true )
368367
368+ const timelineTemplateId = _ . get ( challenge , 'timelineTemplateId' , null ) ;
369+
369370 const ret = await helper . create ( 'Resource' , _ . assign ( {
370371 id : uuid ( ) ,
371372 memberId,
@@ -391,23 +392,26 @@ async function createResource (currentUser, resource) {
391392 if ( _ . isUndefined ( forumUrl ) ) {
392393 templateId = config . REGISTRATION_EMAIL . SENDGRID_TEMPLATE_ID_NO_FORUM
393394 }
394- await helper . postEvent ( config . EMAIL_NOTIFICATIN_TOPIC , {
395- from : config . REGISTRATION_EMAIL . EMAIL_FROM ,
396- replyTo : config . REGISTRATION_EMAIL . EMAIL_FROM ,
397- recipients : [ email ] ,
398- data : {
399- handle,
400- challengeName : challenge . name ,
401- forum : forumUrl ,
402- submissionEndTime : new Date ( _ . get ( _ . find ( challenge . phases , phase => phase . name === 'Submission' ) , 'scheduledEndDate' ) ) . toUTCString ( ) ,
403- submitUrl : _ . replace ( config . REGISTRATION_EMAIL . SUBMIT_URL , ':id' , challengeId ) ,
404- reviewAppUrl : config . REGISTRATION_EMAIL . REVIEW_APP_URL + challenge . legacyId ,
405- helpUrl : config . REGISTRATION_EMAIL . HELP_URL ,
406- support : config . REGISTRATION_EMAIL . SUPPORT_EMAIL
407- } ,
408- sendgrid_template_id : templateId ,
409- version : 'v3'
410- } )
395+
396+ if ( config . get ( 'TOPCROWD_CHALLENGE_TEMPLATE_ID' ) !== timelineTemplateId ) {
397+ await helper . postEvent ( config . EMAIL_NOTIFICATIN_TOPIC , {
398+ from : config . REGISTRATION_EMAIL . EMAIL_FROM ,
399+ replyTo : config . REGISTRATION_EMAIL . EMAIL_FROM ,
400+ recipients : [ email ] ,
401+ data : {
402+ handle,
403+ challengeName : challenge . name ,
404+ forum : forumUrl ,
405+ submissionEndTime : new Date ( _ . get ( _ . find ( challenge . phases , phase => phase . name === 'Submission' ) , 'scheduledEndDate' ) ) . toUTCString ( ) ,
406+ submitUrl : _ . replace ( config . REGISTRATION_EMAIL . SUBMIT_URL , ':id' , challengeId ) ,
407+ reviewAppUrl : config . REGISTRATION_EMAIL . REVIEW_APP_URL + challenge . legacyId ,
408+ helpUrl : config . REGISTRATION_EMAIL . HELP_URL ,
409+ support : config . REGISTRATION_EMAIL . SUPPORT_EMAIL
410+ } ,
411+ sendgrid_template_id : templateId ,
412+ version : 'v3'
413+ } )
414+ }
411415 }
412416
413417 if ( closeRegistration ) {
0 commit comments