Skip to content

Commit a62f34d

Browse files
committed
fix: dont send registration email for topcrowd challenges
Signed-off-by: Rakib Ansary <rakibansary@topcoder.com>
1 parent b407738 commit a62f34d

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ workflows:
107107
branches:
108108
only:
109109
- develop
110-
- PLAT-3501
110+
- TI-70
111111

112112
# Production builds are exectuted only on tagged commits to the testing
113113
# master branch.

config/default.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ module.exports = {
7979
SUPPORT_EMAIL: process.env.SUPPORT_EMAIL || 'support@topcoder.com'
8080
},
8181

82-
AUTOMATED_TESTING_NAME_PREFIX: process.env.AUTOMATED_TESTING_NAME_PREFIX || 'POSTMANE2E-'
82+
AUTOMATED_TESTING_NAME_PREFIX: process.env.AUTOMATED_TESTING_NAME_PREFIX || 'POSTMANE2E-',
83+
TOPCROWD_CHALLENGE_TEMPLATE_ID: process.env.TOPCROWD_CHALLENGE_TEMPLATE_ID || '53a307ce-b4b3-4d6f-b9a1-3741a58f77e6'
8384
}

src/services/ResourceService.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
225225
async function init (currentUser, challengeId, resource, isCreated) {
226226
// Verify that the challenge exists
@@ -363,9 +363,10 @@ async function init (currentUser, challengeId, resource, isCreated) {
363363
async 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

Comments
 (0)