1
1
import _ from 'lodash' ;
2
2
import validate from 'express-validation' ;
3
3
import Joi from 'joi' ;
4
- import config from 'config' ;
5
4
6
5
import models from '../../models' ;
7
6
import util from '../../util' ;
8
7
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' ;
11
9
12
10
const assignCopilotOpportunityValidations = {
13
11
body : Joi . object ( ) . keys ( {
@@ -75,13 +73,6 @@ module.exports = [
75
73
throw err ;
76
74
}
77
75
78
- const project = await models . Project . findOne ( {
79
- where : {
80
- id : projectId ,
81
- } ,
82
- transaction : t ,
83
- } ) ;
84
-
85
76
const existingInvite = await models . ProjectMemberInvite . findAll ( {
86
77
where : {
87
78
userId,
@@ -98,16 +89,12 @@ module.exports = [
98
89
throw err ;
99
90
}
100
91
101
- const applicationUser = await util . getMemberDetailsByUserIds ( [ userId ] , req . log , req . id ) ;
102
- req . log . info ( applicationUser , 'applicationUser asdsd' , userId ) ;
103
-
104
92
const invite = await models . ProjectMemberInvite . create ( {
105
93
status : INVITE_STATUS . PENDING ,
106
94
role : PROJECT_MEMBER_ROLE . COPILOT ,
107
95
userId,
108
96
projectId,
109
97
applicationId : application . id ,
110
- email : applicationUser [ 0 ] . email ,
111
98
createdBy : req . authUser . userId ,
112
99
createdAt : new Date ( ) ,
113
100
updatedBy : req . authUser . userId ,
@@ -122,38 +109,6 @@ module.exports = [
122
109
RESOURCES . PROJECT_MEMBER_INVITE ,
123
110
invite . toJSON ( ) ) ;
124
111
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
-
157
112
await application . update ( {
158
113
status : COPILOT_APPLICATION_STATUS . INVITED ,
159
114
} , {
0 commit comments