diff --git a/README.md b/README.md index 6fa1aa1..740132b 100755 --- a/README.md +++ b/README.md @@ -32,9 +32,6 @@ The following config parameters are supported, they are defined in `config/defau |TC_DEV_ENV| the flag whether to use topcoder development api or production| false| | NEW_CHALLENGE_TEMPLATE | the body template for new challenge request. You can change the subTrack, reviewTypes, technologies, .. here | see `default.js` | | NEW_CHALLENGE_DURATION_IN_DAYS | the duration of new challenge | 5 | -| NODE_MAILER_OPTIONS| the node mailer smtp options, see [here](https://nodemailer.com/smtp/ for more detail)| see `default.js` | -|EMAIL_SENDER_ADDRESS| the email sender email address|| -|ISSUE_BID_EMAIL_RECEIVER| the email receiver about bid email|| |TC_URL| the base URL of topcoder to get the challenge URL| defaults to `https://www.topcoder-dev.com`| |GITLAB_API_BASE_URL| the URL for gitlab host| defaults to `https://gitlab.com`| |PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'tcx_Paid'| diff --git a/config/default.js b/config/default.js index eaa6672..2870aff 100644 --- a/config/default.js +++ b/config/default.js @@ -53,18 +53,6 @@ module.exports = { // NOTE: if subTrack is FIRST_2_FINISH, // this config has no effect since the ***EndsAt will be set automatically by TC APIs NEW_CHALLENGE_DURATION_IN_DAYS: process.env.NEW_CHALLENGE_DURATION_IN_DAYS || 5, - // node mailer option - NODE_MAILER_OPTIONS: { - host: process.env.SMTP_HOST || process.env.MAILGUN_SMTP_SERVER || 'smtp.gmail.com', - port: process.env.SMTP_PORT || process.env.MAILGUN_SMTP_POR || 465, - secure: process.env.SMTP_IS_SECURE || true, - auth: { - user: process.env.SMTP_USERNAME || process.env.MAILGUN_SMTP_LOGIN || '', - pass: process.env.SMTP_PASSWORD || process.env.MAILGUN_SMTP_PASSWORD || '' - } - }, - EMAIL_SENDER_ADDRESS: process.env.EMAIL_SENDER_ADDRESS || '', - ISSUE_BID_EMAIL_RECEIVER: process.env.ISSUE_BID_EMAIL_RECEIVER || '', TC_URL: process.env.TC_URL || 'https://www.topcoder-dev.com', GITLAB_API_BASE_URL: process.env.GITLAB_API_BASE_URL || 'https://gitlab.com', PAID_ISSUE_LABEL: process.env.PAID_ISSUE_LABEL || 'tcx_Paid', diff --git a/configuration.md b/configuration.md index 8e39cff..e7364df 100644 --- a/configuration.md +++ b/configuration.md @@ -14,9 +14,6 @@ The following config parameters are supported, they are defined in `config/defau |TC_DEV_ENV| the flag whether to use topcoder development api or production| false| | NEW_CHALLENGE_TEMPLATE | the body template for new challenge request. You can change the subTrack, reviewTypes, technologies, .. here | see `default.js` | | NEW_CHALLENGE_DURATION_IN_DAYS | the duration of new challenge | 5 | -| NODE_MAILER_OPTIONS| the node mailer smtp options, see [here](https://nodemailer.com/smtp/ for more detail)| see `default.js` | -|EMAIL_SENDER_ADDRESS| the email sender email address|| -|ISSUE_BID_EMAIL_RECEIVER| the email receiver about bid email|| |TC_URL| the base URL of topcoder to get the challenge URL| defaults to `https://www.topcoder-dev.com`| |GITLAB_API_BASE_URL| the URL for gitlab host| defaults to `https://gitlab.com`| |PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'tcx_Paid'| diff --git a/services/EmailService.js b/services/EmailService.js deleted file mode 100644 index 7c73901..0000000 --- a/services/EmailService.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2017 TopCoder, Inc. All rights reserved. - */ -'use strict'; - -/** - * This provides methods for email. - * @author TCSCODER - * @version 1.0 - */ - -const config = require('config'); -const nodemailer = require('nodemailer'); -const Joi = require('joi'); -const logger = require('../utils/logger'); - -// create reusable transporter object using the default SMTP transport -const smtpTransport = nodemailer.createTransport(config.NODE_MAILER_OPTIONS); - -/** - * Sends the email with bid amount. - * @param {Object} issue the issue - * @param {Number} bidAmount the bid amount - */ -async function sendNewBidEmail(issue, bidAmount) { - Joi.validate({issue, bidAmount}, sendNewBidEmail.schema); - - const body = `New bid has been placed on issue '${issue.issue.title}' with amount $${bidAmount} by ${issue.comment.user.name}`; - const mailOptions = { - from: config.EMAIL_SENDER_ADDRESS, - to: config.ISSUE_BID_EMAIL_RECEIVER, - text: body, - subject: 'New bid on issue' - }; - await new Promise((resolve, reject) => { - smtpTransport.sendMail(mailOptions, (err, res) => { - if (err) { - reject(err); - } else { - resolve(res); - } - }); - }); - logger.debug(`bid email is sent to ${config.ISSUE_BID_EMAIL_RECEIVER}`); -} - -sendNewBidEmail.schema = { - issue: Joi.object().keys({ - issue: Joi.object().keys({ - title: Joi.string().required() - }).required(), - comment: Joi.object().keys({ - user: Joi.object().keys({ - id: Joi.number().required(), - name: Joi.string() - }) - }) - }).required(), - bidAmount: Joi.number().required() -}; - -module.exports = { - sendNewBidEmail -}; - -logger.buildService(module.exports); diff --git a/services/EventService.js b/services/EventService.js index 93ff003..b02ca04 100644 --- a/services/EventService.js +++ b/services/EventService.js @@ -11,10 +11,10 @@ const config = require('config'); const _ = require('lodash'); const logger = require('../utils/logger'); -const gitHubService = require('./GithubService'); -const gitlabService = require('./GitlabService'); const models = require('../models'); const dbHelper = require('../utils/db-helper'); +const gitHubService = require('./GithubService'); +const gitlabService = require('./GitlabService'); const timeoutMapper = {}; diff --git a/services/IssueService.js b/services/IssueService.js index 6953a4c..80ee793 100755 --- a/services/IssueService.js +++ b/services/IssueService.js @@ -21,7 +21,6 @@ const models = require('../models'); const dbHelper = require('../utils/db-helper'); const helper = require('../utils/helper'); const gitHelper = require('../utils/git-helper'); -const emailService = require('./EmailService'); const userService = require('./UserService'); const eventService = require('./EventService'); @@ -269,7 +268,6 @@ async function handleIssueComment(event, issue) { const parsedComment = parseComment(event.data.comment); if (parsedComment.isBid) { logger.debug(`New bid is received with amount ${parsedComment.bidAmount}.`); - await emailService.sendNewBidEmail(event.data, parsedComment.bidAmount); } if (parsedComment.isAcceptBid) { logger.debug(`Bid by ${parsedComment.assignedUser} is accepted with amount ${parsedComment.bidAmount} `);