Skip to content

Commit d9d9cd4

Browse files
authored
Merge pull request #811 from topcoder-platform/pm-1168_2
fix(PM-1168): Email template while inviting copilot
2 parents 5151cfa + cf0236d commit d9d9cd4

File tree

3 files changed

+3
-48
lines changed

3 files changed

+3
-48
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ workflows:
149149
context : org-global
150150
filters:
151151
branches:
152-
only: ['develop', 'migration-setup', 'pm-1168_2']
152+
only: ['develop', 'migration-setup']
153153
- deployProd:
154154
context : org-global
155155
filters:

src/events/busApi.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ module.exports = (app, logger) => {
992992
/*
993993
Send event for Notification Service
994994
*/
995-
const projectId = _.parseInt(req.params.projectId);
995+
const projectId = resource.projectId;
996996
const userId = resource.userId;
997997
const email = resource.email;
998998
const status = resource.status;

src/routes/copilotOpportunity/assign.js

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import _ from 'lodash';
22
import validate from 'express-validation';
33
import Joi from 'joi';
4-
import config from 'config';
54

65
import models from '../../models';
76
import util from '../../util';
87
import { PERMISSION } from '../../permissions/constants';
9-
import { createEvent } from '../../services/busApi';
10-
import { CONNECT_NOTIFICATION_EVENT, COPILOT_APPLICATION_STATUS, COPILOT_OPPORTUNITY_STATUS, COPILOT_REQUEST_STATUS, EVENT, INVITE_STATUS, PROJECT_MEMBER_ROLE, RESOURCES } from '../../constants';
8+
import { COPILOT_APPLICATION_STATUS, COPILOT_OPPORTUNITY_STATUS, COPILOT_REQUEST_STATUS, EVENT, INVITE_STATUS, PROJECT_MEMBER_ROLE, RESOURCES } from '../../constants';
119

1210
const assignCopilotOpportunityValidations = {
1311
body: Joi.object().keys({
@@ -75,13 +73,6 @@ module.exports = [
7573
throw err;
7674
}
7775

78-
const project = await models.Project.findOne({
79-
where: {
80-
id: projectId,
81-
},
82-
transaction: t,
83-
});
84-
8576
const existingInvite = await models.ProjectMemberInvite.findAll({
8677
where: {
8778
userId,
@@ -98,16 +89,12 @@ module.exports = [
9889
throw err;
9990
}
10091

101-
const applicationUser = await util.getMemberDetailsByUserIds([userId], req.log, req.id);
102-
req.log.info(applicationUser, 'applicationUser asdsd', userId);
103-
10492
const invite = await models.ProjectMemberInvite.create({
10593
status: INVITE_STATUS.PENDING,
10694
role: PROJECT_MEMBER_ROLE.COPILOT,
10795
userId,
10896
projectId,
10997
applicationId: application.id,
110-
email: applicationUser[0].email,
11198
createdBy: req.authUser.userId,
11299
createdAt: new Date(),
113100
updatedBy: req.authUser.userId,
@@ -122,38 +109,6 @@ module.exports = [
122109
RESOURCES.PROJECT_MEMBER_INVITE,
123110
invite.toJSON());
124111

125-
const authUserDetails = await util.getMemberDetailsByUserIds([req.authUser.userId], req.log, req.id);
126-
127-
const emailEventType = CONNECT_NOTIFICATION_EVENT.PROJECT_MEMBER_EMAIL_INVITE_CREATED;
128-
await createEvent(emailEventType, {
129-
data: {
130-
workManagerUrl: config.get('workManagerUrl'),
131-
accountsAppURL: config.get('accountsAppUrl'),
132-
subject: config.get('inviteEmailSubject'),
133-
projects: [{
134-
name: project.name,
135-
projectId,
136-
sections: [
137-
{
138-
EMAIL_INVITES: true,
139-
title: config.get('inviteEmailSectionTitle'),
140-
projectName: project.name,
141-
projectId,
142-
initiator: authUserDetails[0],
143-
isSSO: util.isSSO(project),
144-
},
145-
],
146-
}],
147-
},
148-
recipients: [applicationUser[0].email],
149-
version: 'v3',
150-
from: {
151-
name: config.get('EMAIL_INVITE_FROM_NAME'),
152-
email: config.get('EMAIL_INVITE_FROM_EMAIL'),
153-
},
154-
categories: [`${process.env.NODE_ENV}:${emailEventType}`.toLowerCase()],
155-
}, req.log);
156-
157112
await application.update({
158113
status: COPILOT_APPLICATION_STATUS.INVITED,
159114
}, {

0 commit comments

Comments
 (0)