Skip to content

Commit c3382be

Browse files
author
vikasrohit
authored
Merge pull request #76 from topcoder-platform/dev
Supporting release for Connect 2.4.7
2 parents 01ad275 + 2e8d09b commit c3382be

19 files changed

+122
-123
lines changed

connect/connectNotificationServer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ if (config.ENABLE_EMAILS) {
361361
}
362362

363363
// init database, it will clear and re-create all tables
364-
notificationServer
365-
.initDatabase()
366-
.then(() => notificationServer.start())
367-
.catch((e) => {
368-
console.log(e); // eslint-disable-line no-console
369-
notificationServer.logger.error('Notification server errored out');
370-
});
364+
// notificationServer
365+
// .initDatabase()
366+
// .then(() => notificationServer.startKafkaConsumers())
367+
// .catch((e) => {
368+
// console.log(e); // eslint-disable-line no-console
369+
// notificationServer.logger.error('Notification server errored out');
370+
// });
371371

372372
// if no need to init database, then directly start the server:
373-
// notificationServer.start();
373+
notificationServer.startKafkaConsumers();

connect/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = {
1111
// email service id for settings
1212
SETTINGS_EMAIL_SERVICE_ID: 'email',
1313
SETTINGS_EMAIL_BUNDLING_SERVICE_ID: 'emailBundling',
14+
ACTIVE_USER_STATUSES: ['ACTIVE'],
1415

1516
BUS_API_EVENT: {
1617
CONNECT: {
@@ -38,7 +39,7 @@ module.exports = {
3839
LINK_CREATED: 'notifications.connect.project.linkCreated',
3940
PAUSED: 'notifications.connect.project.paused',
4041
SUBMITTED_FOR_REVIEW: 'notifications.connect.project.submittedForReview',
41-
SPECIFICATION_MODIFIED: 'connect.action.project.product.update.spec',
42+
SPECIFICATION_MODIFIED: 'connect.action.project.updated.spec',
4243
},
4344
PROJECT_PLAN: {
4445
READY: 'connect.action.project.plan.ready',
@@ -49,9 +50,11 @@ module.exports = {
4950
PHASE_PAYMENT_UPDATED: 'notifications.connect.project.phase.update.payment',
5051
PHASE_PROGRESS_UPDATED: 'notifications.connect.project.phase.update.progress',
5152
PHASE_SCOPE_UPDATED: 'notifications.connect.project.phase.update.scope',
53+
PHASE_PRODUCT_SPEC_UPDATED: 'connect.action.project.product.update.spec',
5254
MILESTONE_ACTIVATED: 'connect.action.timeline.milestone.transition.active',
5355
MILESTONE_COMPLETED: 'connect.action.timeline.milestone.transition.completed',
5456
WAITING_FOR_CUSTOMER_INPUT: 'connect.action.timeline.milestone.waiting.customer',
57+
TIMELINE_ADJUSTED: 'connect.action.timeline.adjusted',
5558
},
5659
TOPIC: {
5760
CREATED: 'notifications.connect.project.topic.created',

connect/events-config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ const EVENTS = [
176176
}, {
177177
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_SCOPE_UPDATED,
178178
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
179+
}, {
180+
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PRODUCT_SPEC_UPDATED,
181+
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
179182
},
180183

181184
// Timeline/Milestone activity
@@ -188,6 +191,9 @@ const EVENTS = [
188191
}, {
189192
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.WAITING_FOR_CUSTOMER_INPUT,
190193
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
194+
}, {
195+
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.TIMELINE_ADJUSTED,
196+
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
191197
}
192198
];
193199

@@ -263,6 +269,7 @@ const EVENT_BUNDLES = {
263269
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PAYMENT_UPDATED,
264270
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PROGRESS_UPDATED,
265271
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_SCOPE_UPDATED,
272+
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PRODUCT_SPEC_UPDATED,
266273
BUS_API_EVENT.CONNECT.PROJECT_PLAN.MILESTONE_ACTIVATED,
267274
BUS_API_EVENT.CONNECT.PROJECT_PLAN.MILESTONE_COMPLETED,
268275
BUS_API_EVENT.CONNECT.PROJECT_PLAN.WAITING_FOR_CUSTOMER_INPUT,

connect/notificationServices/email.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const {
1414
BUS_API_EVENT,
1515
SCHEDULED_EVENT_PERIOD,
1616
SETTINGS_EMAIL_SERVICE_ID,
17-
SETTINGS_EMAIL_BUNDLING_SERVICE_ID
17+
ACTIVE_USER_STATUSES
1818
} = require('../constants');
1919
const { EVENTS, EVENT_BUNDLES } = require('../events-config');
2020
const helpers = require('../helpers');
@@ -200,12 +200,20 @@ function handler(topicName, messageJSON, notification) {
200200
}
201201

202202
const users = yield service.getUsersById([notification.userId]);
203-
logger.debug(`got users ${JSON.stringify(users)}`);
203+
logger.verbose(`got users ${JSON.stringify(users)}`);
204204

205-
const user = users[0];
206-
let userEmail = user.email;
205+
const user = users && users.length > 0 ? users[0] : null;
206+
let userEmail = _.get(user, 'email');
207207
if (!userEmail) {
208208
logger.error(`Email not received for user: ${user.id}`);
209+
return;
210+
}
211+
const userStatus = _.get(user, 'status');
212+
// don't send email notification for inactive users, ideally we should not have generated
213+
// notifications for inactive users, however, for now handling it here as safe gaurd
214+
if (userStatus && ACTIVE_USER_STATUSES.indexOf(userStatus) === -1) {
215+
logger.error(`Notification generated for inactive user, ignoring`);
216+
return;
209217
}
210218
if (config.ENABLE_DEV_MODE === 'true') {
211219
userEmail = config.DEV_MODE_EMAIL;

connect/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const getUsersById = (ids) => {
8989
})
9090
.then((token) => {
9191
return request
92-
.get(`${config.TC_API_V3_BASE_URL}/members/_search?fields=userId,email,handle,firstName,lastName,photoURL&query=${query}`)
92+
.get(`${config.TC_API_V3_BASE_URL}/members/_search?fields=userId,email,handle,firstName,lastName,photoURL,status&query=${query}`)
9393
.set('accept', 'application/json')
9494
.set('authorization', `Bearer ${token}`)
9595
.then((res) => {

deploy.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY")
2929
AWS_ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
3030
AWS_REPOSITORY=$(eval "echo \$${ENV}_AWS_REPOSITORY")
3131
AWS_ECS_CLUSTER=$(eval "echo \$${ENV}_AWS_ECS_CLUSTER")
32-
AWS_ECS_SERVICE=$(eval "echo \$${ENV}_AWS_ECS_SERVICE")
32+
AWS_ECS_SERVICE_API=$(eval "echo \$${ENV}_AWS_ECS_SERVICE")
33+
AWS_ECS_SERVICE_CONSUMERS=$(eval "echo \$${ENV}_AWS_ECS_SERVICE_CONSUMERS")
3334

3435
KAFKA_CLIENT_CERT=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT")
3536
KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
@@ -99,9 +100,9 @@ deploy_cluster() {
99100

100101
#family="nginx-api-dev-task"
101102

102-
make_task_def
103-
register_definition
104-
update_result=$(aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $AWS_ECS_SERVICE --task-definition $revision )
103+
make_task_def $1 $2 $3 $4
104+
register_definition $1
105+
update_result=$(aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $1 --task-definition $revision )
105106
#echo $update_result
106107
result=$(echo $update_result | $JQ '.service.taskDefinition' )
107108
echo $result
@@ -120,8 +121,9 @@ make_task_def(){
120121
"name": "%s",
121122
"image": "%s.dkr.ecr.%s.amazonaws.com/%s:%s",
122123
"essential": true,
123-
"memory": 1536,
124-
"cpu": 768,
124+
"memory": 768,
125+
"cpu": 512,
126+
"entryPoint": ["%s", "%s", "%s"],
125127
"environment": [
126128
{
127129
"name": "ENV",
@@ -266,11 +268,11 @@ make_task_def(){
266268
}
267269
]'
268270

269-
task_def=$(printf "$task_template" $AWS_ECS_CONTAINER_NAME $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $DATABASE_URL $AUTHSECRET $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $CONNECT_URL $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $REPLY_EMAIL_FROM $DEFAULT_REPLY_EMAIL $ENABLE_DEV_MODE $DEV_MODE_EMAIL $LOG_LEVEL $VALID_ISSUERS $PORT "$API_CONTEXT_PATH" "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
271+
task_def=$(printf "$task_template" $1 $AWS_ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $TAG $2 $3 $4 $ENV "$KAFKA_CLIENT_CERT" "$KAFKA_CLIENT_CERT_KEY" $KAFKA_GROUP_ID $KAFKA_URL $DATABASE_URL $AUTHSECRET $TC_API_BASE_URL $TC_API_V3_BASE_URL $TC_API_V4_BASE_URL $TC_API_V5_BASE_URL $MESSAGE_API_BASE_URL $CONNECT_URL $ENABLE_EMAILS $MENTION_EMAIL $REPLY_EMAIL_PREFIX $REPLY_EMAIL_DOMAIN $REPLY_EMAIL_FROM $DEFAULT_REPLY_EMAIL $ENABLE_DEV_MODE $DEV_MODE_EMAIL $LOG_LEVEL $VALID_ISSUERS $PORT "$API_CONTEXT_PATH" "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" $AWS_ECS_CLUSTER $AWS_REGION $AWS_ECS_CLUSTER $ENV)
270272
}
271273

272274
register_definition() {
273-
if revision=$(aws ecs register-task-definition --container-definitions "$task_def" --family $family | $JQ '.taskDefinition.taskDefinitionArn'); then
275+
if revision=$(aws ecs register-task-definition --container-definitions "$task_def" --family $1 2> /dev/null | $JQ '.taskDefinition.taskDefinitionArn'); then
274276
echo "Revision: $revision"
275277
else
276278
echo "Failed to register task definition"
@@ -282,13 +284,13 @@ register_definition() {
282284
check_service_status() {
283285
counter=0
284286
sleep 60
285-
servicestatus=`aws ecs describe-services --service $AWS_ECS_SERVICE --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
287+
servicestatus=`aws ecs describe-services --service $1 --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
286288
while [[ $servicestatus != *"steady state"* ]]
287289
do
288290
echo "Current event message : $servicestatus"
289291
echo "Waiting for 30 seconds to check the service status...."
290292
sleep 30
291-
servicestatus=`aws ecs describe-services --service $AWS_ECS_SERVICE --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
293+
servicestatus=`aws ecs describe-services --service $1 --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
292294
counter=`expr $counter + 1`
293295
if [[ $counter -gt $COUNTER_LIMIT ]] ; then
294296
echo "Service does not reach steady state within 10 minutes. Please check"
@@ -300,5 +302,11 @@ check_service_status() {
300302

301303
configure_aws_cli
302304
push_ecr_image
303-
deploy_cluster
304-
check_service_status
305+
306+
deploy_cluster $AWS_ECS_SERVICE_API "npm" "run" "startAPI"
307+
308+
deploy_cluster $AWS_ECS_SERVICE_CONSUMERS "npm" "run" "start"
309+
310+
check_service_status $AWS_ECS_SERVICE_API
311+
312+
check_service_status $AWS_ECS_SERVICE_CONSUMERS

emails/src/partials/project-files.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@
6060
<td class="empty-child-one"></td>
6161
<td class="second-child" align="center">
6262
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
63-
<table>
64-
<tr><td align="center">View project on Connect</td></tr>
65-
</table>
63+
View project on Connect
6664
</a>
6765
</td>
6866
<td class="empty-child-one"></td>

emails/src/partials/project-links.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@
3131
<td class="empty-child-one"></td>
3232
<td class="second-child" align="center">
3333
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
34-
<table>
35-
<tr><td align="center">View project on Connect</td></tr>
36-
</table>
34+
View project on Connect
3735
</a>
3836
</td>
3937
<td class="empty-child-one"></td>

emails/src/partials/project-plan.html

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
<tr class="row-child-one" height="20">
3636
<td class="empty-child-one"></td>
3737
<td>
38-
{{#if [notifications.connect.project.planReady]}}
38+
{{#if [connect.action.project.plan.ready]}}
3939
Project plan is ready for your project
4040
{{/if}}
41-
{{#if [notifications.connect.project.plan.updated]}}
41+
{{#if [connect.action.project.plan.updated]}}
4242
Project plan is modified for your project
4343
{{/if}}
44-
{{#if [notifications.connect.project.progressModified]}}
44+
{{#if [connect.action.project.updated.progress]}}
4545
Your project has made some progress
4646
{{/if}}
4747
{{#if [notifications.connect.project.phase.transition.active]}}
@@ -59,13 +59,16 @@
5959
{{#if [notifications.connect.project.phase.update.scope]}}
6060
Scope of the phase <strong>{{updatedPhase.name}}</strong> updated
6161
{{/if}}
62-
{{#if [notifications.connect.project.phase.milestone.transition.active]}}
62+
{{#if [connect.action.project.product.update.spec]}}
63+
Scope of the phase <strong>{{updatedPhase.name}}</strong> updated
64+
{{/if}}
65+
{{#if [connect.action.timeline.milestone.transition.active]}}
6366
A milestone is activated in phase <strong>{{updatedPhase.name}}</strong>
6467
{{/if}}
65-
{{#if [notifications.connect.project.phase.milestone.transition.completed]}}
68+
{{#if [connect.action.timeline.milestone.transition.completed]}}
6669
A milestone is completed in phase <strong>{{updatedPhase.name}}</strong>
6770
{{/if}}
68-
{{#if [notifications.connect.project.phase.milestone.waiting.customer]}}
71+
{{#if [connect.action.timeline.milestone.waiting.customer]}}
6972
We are waiting for your input at a milestone in the phase <strong>{{updatedPhase.name}}</strong>
7073
{{/if}}
7174
</td>
@@ -94,9 +97,7 @@
9497
<td class="empty-child-one"></td>
9598
<td class="second-child" align="center">
9699
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}/plan">
97-
<table>
98-
<tr><td align="center">View plan on Connect</td></tr>
99-
</table>
100+
View plan on Connect
100101
</a>
101102
</td>
102103
<td class="empty-child-one"></td>

emails/src/partials/project-specification.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@
3030
<td class="empty-child-one"></td>
3131
<td class="second-child" align="center">
3232
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
33-
<table>
34-
<tr><td align="center">View project on Connect</td></tr>
35-
</table>
33+
View project on Connect
3634
</a>
3735
</td>
3836
<td class="empty-child-one"></td>

emails/src/partials/project-status.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@
8282
<td class="empty-child-one"></td>
8383
<td class="second-child" align="center">
8484
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
85-
<table>
86-
<tr><td align="center">View project on Connect</td></tr>
87-
</table>
85+
View project on Connect
8886
</a>
8987
</td>
9088
<td class="empty-child-one"></td>

emails/src/partials/project-team.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@
7979
<td class="empty-child-one"></td>
8080
<td class="second-child" align="center">
8181
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
82-
<table>
83-
<tr><td align="center">View project on Connect</td></tr>
84-
</table>
82+
View project on Connect
8583
</a>
8684
</td>
8785
<td class="empty-child-one"></td>

emails/src/partials/topics_and_posts.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@
171171
<td class="empty-child-one"></td>
172172
<td class="second-child" align="center">
173173
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}">
174-
<table>
175-
<tr><td align="center">View post on Connect</td></tr>
176-
</table>
174+
View post on Connect
177175
</a>
178176
</td>
179177
<td class="empty-child-one"></td>

emails/src/styles/main.css

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,16 @@ table.container, table.footer-container {
210210
background-color: #0681FF;
211211
height: 30px; }
212212
.button-row .main-child .second-child a {
213-
height: 30px;
214213
border-radius: 4px;
215214
text-align: center;
216215
text-decoration: none;
217216
display: block;
218-
background-color: #0681FF; }
219-
.button-row .main-child .second-child a table {
220-
background-color: #0681FF;
221-
border-radius: 4px;
222-
height: 30px; }
223-
.button-row .main-child .second-child a table td {
224-
height: 30px;
225-
background-color: #0681FF;
226-
border-radius: 4px;
227-
vertical-align: middle;
228-
text-align: center;
229-
color: #FFFFFF;
230-
font-size: 13px; }
217+
background-color: #0681FF;
218+
padding-top: 6px;
219+
padding-bottom: 5px;
220+
text-align: center;
221+
color: #FFFFFF;
222+
font-size: 13px; }
231223

232224
.button-one .main-child .empty-child-one, .button-three .main-child .empty-child-one {
233225
width: 216px; }
@@ -236,8 +228,6 @@ table.container, table.footer-container {
236228
width: 167px; }
237229
.button-one .main-child .second-child a, .button-three .main-child .second-child a {
238230
width: 167px; }
239-
.button-one .main-child .second-child a table td, .button-three .main-child .second-child a table td {
240-
width: 167px; }
241231

242232
.button-two .main-child .empty-child-one {
243233
width: 211px; }
@@ -246,8 +236,6 @@ table.container, table.footer-container {
246236
width: 178px; }
247237
.button-two .main-child .second-child a {
248238
width: 178px; }
249-
.button-two .main-child .second-child a table td {
250-
width: 178px; }
251239

252240
.button-four .main-child .empty-child-one {
253241
width: 210px; }
@@ -256,8 +244,6 @@ table.container, table.footer-container {
256244
width: 180px; }
257245
.button-four .main-child .second-child a {
258246
width: 180px; }
259-
.button-four .main-child .second-child a table td {
260-
width: 180px; }
261247

262248
.copy-link {
263249
height: 20px; }

0 commit comments

Comments
 (0)