Skip to content

Commit a3ce242

Browse files
authored
Merge pull request #124 from topcoder-platform/fix/PLAT-2906
use different template for challenges without forum
2 parents 71d4f93 + 2020929 commit a3ce242

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

config/default.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ module.exports = {
7272
REGISTRATION_EMAIL: {
7373
EMAIL_FROM: process.env.EMAIL_FROM || '[email protected]',
7474
SENDGRID_TEMPLATE_ID: process.env.SENDGRID_TEMPLATE_ID || '',
75+
SENDGRID_TEMPLATE_ID_NO_FORUM: process.env.SENDGRID_TEMPLATE_ID_NO_FORUM || '',
7576
SUBMIT_URL: process.env.SUBMIT_URL || 'https://www.topcoder.com/challenges/:id/submit/',
76-
REVIEW_APP_URL: process.env.REVIEW_APP_URL || 'https://software.topcoder.com/review',
77+
REVIEW_APP_URL: process.env.REVIEW_APP_URL || 'https://software.topcoder.com/review/actions/ViewProjectDetails?pid=',
7778
HELP_URL: process.env.HELP_URL || 'https://help.topcoder.com',
7879
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL || '[email protected]'
7980
},

src/services/ResourceService.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -359,21 +359,26 @@ async function createResource (currentUser, resource) {
359359
logger.debug(`Created resource: ${JSON.stringify(_.pick(ret, payloadFields))}`)
360360
await helper.postEvent(config.RESOURCE_CREATE_TOPIC, _.pick(ret, payloadFields))
361361
if (!_.get(challenge, 'task.isTask', false) && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
362+
const forumUrl = _.get(challenge, 'discussions[0].url')
363+
let templateId = config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID
364+
if (_.isUndefined(forumUrl)) {
365+
templateId = config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID_NO_FORUM
366+
}
362367
await helper.postEvent(config.EMAIL_NOTIFICATIN_TOPIC, {
363368
from: config.REGISTRATION_EMAIL.EMAIL_FROM,
364369
replyTo: config.REGISTRATION_EMAIL.EMAIL_FROM,
365370
recipients: [email],
366371
data: {
367372
handle,
368373
challengeName: challenge.name,
369-
forum: _.get(challenge, 'discussions[0].url'),
370-
submissionEndTime: _.get(_.find(challenge.phases, phase => phase.name === 'Submission'), 'scheduledEndDate'),
374+
forum: forumUrl,
375+
submissionEndTime: new Date(_.get(_.find(challenge.phases, phase => phase.name === 'Submission'), 'scheduledEndDate')).toUTCString(),
371376
submitUrl: _.replace(config.REGISTRATION_EMAIL.SUBMIT_URL, ':id', challengeId),
372-
reviewAppUrl: config.REGISTRATION_EMAIL.REVIEW_APP_URL,
377+
reviewAppUrl: config.REGISTRATION_EMAIL.REVIEW_APP_URL + challenge.legacyId,
373378
helpUrl: config.REGISTRATION_EMAIL.HELP_URL,
374379
support: config.REGISTRATION_EMAIL.SUPPORT_EMAIL
375380
},
376-
sendgrid_template_id: config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID,
381+
sendgrid_template_id: templateId,
377382
version: 'v3'
378383
})
379384
}

0 commit comments

Comments
 (0)