Skip to content

feat: send registration email #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 11, 2023
Prev Previous commit
Next Next commit
use different template for challenges without forum
  • Loading branch information
eisbilir committed May 11, 2023
commit 20209296bf59a6bd5d76d52ef9c03411f7327be2
3 changes: 2 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ module.exports = {
REGISTRATION_EMAIL: {
EMAIL_FROM: process.env.EMAIL_FROM || '[email protected]',
SENDGRID_TEMPLATE_ID: process.env.SENDGRID_TEMPLATE_ID || '',
SENDGRID_TEMPLATE_ID_NO_FORUM: process.env.SENDGRID_TEMPLATE_ID_NO_FORUM || '',
SUBMIT_URL: process.env.SUBMIT_URL || 'https://www.topcoder.com/challenges/:id/submit/',
REVIEW_APP_URL: process.env.REVIEW_APP_URL || 'https://software.topcoder.com/review',
REVIEW_APP_URL: process.env.REVIEW_APP_URL || 'https://software.topcoder.com/review/actions/ViewProjectDetails?pid=',
HELP_URL: process.env.HELP_URL || 'https://help.topcoder.com',
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL || '[email protected]'
},
Expand Down
13 changes: 9 additions & 4 deletions src/services/ResourceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,21 +359,26 @@ async function createResource (currentUser, resource) {
logger.debug(`Created resource: ${JSON.stringify(_.pick(ret, payloadFields))}`)
await helper.postEvent(config.RESOURCE_CREATE_TOPIC, _.pick(ret, payloadFields))
if (!_.get(challenge, 'task.isTask', false) && resource.roleId === config.SUBMITTER_RESOURCE_ROLE_ID) {
const forumUrl = _.get(challenge, 'discussions[0].url')
let templateId = config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID
if (_.isUndefined(forumUrl)) {
templateId = config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID_NO_FORUM
}
await helper.postEvent(config.EMAIL_NOTIFICATIN_TOPIC, {
from: config.REGISTRATION_EMAIL.EMAIL_FROM,
replyTo: config.REGISTRATION_EMAIL.EMAIL_FROM,
recipients: [email],
data: {
handle,
challengeName: challenge.name,
forum: _.get(challenge, 'discussions[0].url'),
submissionEndTime: _.get(_.find(challenge.phases, phase => phase.name === 'Submission'), 'scheduledEndDate'),
forum: forumUrl,
submissionEndTime: new Date(_.get(_.find(challenge.phases, phase => phase.name === 'Submission'), 'scheduledEndDate')).toUTCString(),
submitUrl: _.replace(config.REGISTRATION_EMAIL.SUBMIT_URL, ':id', challengeId),
reviewAppUrl: config.REGISTRATION_EMAIL.REVIEW_APP_URL,
reviewAppUrl: config.REGISTRATION_EMAIL.REVIEW_APP_URL + challenge.legacyId,
helpUrl: config.REGISTRATION_EMAIL.HELP_URL,
support: config.REGISTRATION_EMAIL.SUPPORT_EMAIL
},
sendgrid_template_id: config.REGISTRATION_EMAIL.SENDGRID_TEMPLATE_ID,
sendgrid_template_id: templateId,
version: 'v3'
})
}
Expand Down