Skip to content

Supporting release for Connect 2.4.7 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions connect/connectNotificationServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,13 @@ if (config.ENABLE_EMAILS) {
}

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

// if no need to init database, then directly start the server:
// notificationServer.start();
notificationServer.startKafkaConsumers();
5 changes: 4 additions & 1 deletion connect/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
// email service id for settings
SETTINGS_EMAIL_SERVICE_ID: 'email',
SETTINGS_EMAIL_BUNDLING_SERVICE_ID: 'emailBundling',
ACTIVE_USER_STATUSES: ['ACTIVE'],

BUS_API_EVENT: {
CONNECT: {
Expand Down Expand Up @@ -38,7 +39,7 @@ module.exports = {
LINK_CREATED: 'notifications.connect.project.linkCreated',
PAUSED: 'notifications.connect.project.paused',
SUBMITTED_FOR_REVIEW: 'notifications.connect.project.submittedForReview',
SPECIFICATION_MODIFIED: 'connect.action.project.product.update.spec',
SPECIFICATION_MODIFIED: 'connect.action.project.updated.spec',
},
PROJECT_PLAN: {
READY: 'connect.action.project.plan.ready',
Expand All @@ -49,9 +50,11 @@ module.exports = {
PHASE_PAYMENT_UPDATED: 'notifications.connect.project.phase.update.payment',
PHASE_PROGRESS_UPDATED: 'notifications.connect.project.phase.update.progress',
PHASE_SCOPE_UPDATED: 'notifications.connect.project.phase.update.scope',
PHASE_PRODUCT_SPEC_UPDATED: 'connect.action.project.product.update.spec',
MILESTONE_ACTIVATED: 'connect.action.timeline.milestone.transition.active',
MILESTONE_COMPLETED: 'connect.action.timeline.milestone.transition.completed',
WAITING_FOR_CUSTOMER_INPUT: 'connect.action.timeline.milestone.waiting.customer',
TIMELINE_ADJUSTED: 'connect.action.timeline.adjusted',
},
TOPIC: {
CREATED: 'notifications.connect.project.topic.created',
Expand Down
7 changes: 7 additions & 0 deletions connect/events-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ const EVENTS = [
}, {
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_SCOPE_UPDATED,
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
}, {
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PRODUCT_SPEC_UPDATED,
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
},

// Timeline/Milestone activity
Expand All @@ -188,6 +191,9 @@ const EVENTS = [
}, {
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.WAITING_FOR_CUSTOMER_INPUT,
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
}, {
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.TIMELINE_ADJUSTED,
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER],
}
];

Expand Down Expand Up @@ -263,6 +269,7 @@ const EVENT_BUNDLES = {
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PAYMENT_UPDATED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PROGRESS_UPDATED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_SCOPE_UPDATED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_PRODUCT_SPEC_UPDATED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.MILESTONE_ACTIVATED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.MILESTONE_COMPLETED,
BUS_API_EVENT.CONNECT.PROJECT_PLAN.WAITING_FOR_CUSTOMER_INPUT,
Expand Down
16 changes: 12 additions & 4 deletions connect/notificationServices/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const {
BUS_API_EVENT,
SCHEDULED_EVENT_PERIOD,
SETTINGS_EMAIL_SERVICE_ID,
SETTINGS_EMAIL_BUNDLING_SERVICE_ID
ACTIVE_USER_STATUSES
} = require('../constants');
const { EVENTS, EVENT_BUNDLES } = require('../events-config');
const helpers = require('../helpers');
Expand Down Expand Up @@ -200,12 +200,20 @@ function handler(topicName, messageJSON, notification) {
}

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

const user = users[0];
let userEmail = user.email;
const user = users && users.length > 0 ? users[0] : null;
let userEmail = _.get(user, 'email');
if (!userEmail) {
logger.error(`Email not received for user: ${user.id}`);
return;
}
const userStatus = _.get(user, 'status');
// don't send email notification for inactive users, ideally we should not have generated
// notifications for inactive users, however, for now handling it here as safe gaurd
if (userStatus && ACTIVE_USER_STATUSES.indexOf(userStatus) === -1) {
logger.error(`Notification generated for inactive user, ignoring`);
return;
}
if (config.ENABLE_DEV_MODE === 'true') {
userEmail = config.DEV_MODE_EMAIL;
Expand Down
2 changes: 1 addition & 1 deletion connect/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const getUsersById = (ids) => {
})
.then((token) => {
return request
.get(`${config.TC_API_V3_BASE_URL}/members/_search?fields=userId,email,handle,firstName,lastName,photoURL&query=${query}`)
.get(`${config.TC_API_V3_BASE_URL}/members/_search?fields=userId,email,handle,firstName,lastName,photoURL,status&query=${query}`)
.set('accept', 'application/json')
.set('authorization', `Bearer ${token}`)
.then((res) => {
Expand Down
32 changes: 20 additions & 12 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV}_AWS_SECRET_ACCESS_KEY")
AWS_ACCOUNT_ID=$(eval "echo \$${ENV}_AWS_ACCOUNT_ID")
AWS_REPOSITORY=$(eval "echo \$${ENV}_AWS_REPOSITORY")
AWS_ECS_CLUSTER=$(eval "echo \$${ENV}_AWS_ECS_CLUSTER")
AWS_ECS_SERVICE=$(eval "echo \$${ENV}_AWS_ECS_SERVICE")
AWS_ECS_SERVICE_API=$(eval "echo \$${ENV}_AWS_ECS_SERVICE")
AWS_ECS_SERVICE_CONSUMERS=$(eval "echo \$${ENV}_AWS_ECS_SERVICE_CONSUMERS")

KAFKA_CLIENT_CERT=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT")
KAFKA_CLIENT_CERT_KEY=$(eval "echo \$${ENV}_KAFKA_CLIENT_CERT_KEY")
Expand Down Expand Up @@ -99,9 +100,9 @@ deploy_cluster() {

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

make_task_def
register_definition
update_result=$(aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $AWS_ECS_SERVICE --task-definition $revision )
make_task_def $1 $2 $3 $4
register_definition $1
update_result=$(aws ecs update-service --cluster $AWS_ECS_CLUSTER --service $1 --task-definition $revision )
#echo $update_result
result=$(echo $update_result | $JQ '.service.taskDefinition' )
echo $result
Expand All @@ -120,8 +121,9 @@ make_task_def(){
"name": "%s",
"image": "%s.dkr.ecr.%s.amazonaws.com/%s:%s",
"essential": true,
"memory": 1536,
"cpu": 768,
"memory": 768,
"cpu": 512,
"entryPoint": ["%s", "%s", "%s"],
"environment": [
{
"name": "ENV",
Expand Down Expand Up @@ -266,11 +268,11 @@ make_task_def(){
}
]'

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)
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)
}

register_definition() {
if revision=$(aws ecs register-task-definition --container-definitions "$task_def" --family $family | $JQ '.taskDefinition.taskDefinitionArn'); then
if revision=$(aws ecs register-task-definition --container-definitions "$task_def" --family $1 2> /dev/null | $JQ '.taskDefinition.taskDefinitionArn'); then
echo "Revision: $revision"
else
echo "Failed to register task definition"
Expand All @@ -282,13 +284,13 @@ register_definition() {
check_service_status() {
counter=0
sleep 60
servicestatus=`aws ecs describe-services --service $AWS_ECS_SERVICE --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
servicestatus=`aws ecs describe-services --service $1 --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
while [[ $servicestatus != *"steady state"* ]]
do
echo "Current event message : $servicestatus"
echo "Waiting for 30 seconds to check the service status...."
sleep 30
servicestatus=`aws ecs describe-services --service $AWS_ECS_SERVICE --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
servicestatus=`aws ecs describe-services --service $1 --cluster $AWS_ECS_CLUSTER | $JQ '.services[].events[0].message'`
counter=`expr $counter + 1`
if [[ $counter -gt $COUNTER_LIMIT ]] ; then
echo "Service does not reach steady state within 10 minutes. Please check"
Expand All @@ -300,5 +302,11 @@ check_service_status() {

configure_aws_cli
push_ecr_image
deploy_cluster
check_service_status

deploy_cluster $AWS_ECS_SERVICE_API "npm" "run" "startAPI"

deploy_cluster $AWS_ECS_SERVICE_CONSUMERS "npm" "run" "start"

check_service_status $AWS_ECS_SERVICE_API

check_service_status $AWS_ECS_SERVICE_CONSUMERS
4 changes: 1 addition & 3 deletions emails/src/partials/project-files.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
<table>
<tr><td align="center">View project on Connect</td></tr>
</table>
View project on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
4 changes: 1 addition & 3 deletions emails/src/partials/project-links.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
<table>
<tr><td align="center">View project on Connect</td></tr>
</table>
View project on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
19 changes: 10 additions & 9 deletions emails/src/partials/project-plan.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
<tr class="row-child-one" height="20">
<td class="empty-child-one"></td>
<td>
{{#if [notifications.connect.project.planReady]}}
{{#if [connect.action.project.plan.ready]}}
Project plan is ready for your project
{{/if}}
{{#if [notifications.connect.project.plan.updated]}}
{{#if [connect.action.project.plan.updated]}}
Project plan is modified for your project
{{/if}}
{{#if [notifications.connect.project.progressModified]}}
{{#if [connect.action.project.updated.progress]}}
Your project has made some progress
{{/if}}
{{#if [notifications.connect.project.phase.transition.active]}}
Expand All @@ -59,13 +59,16 @@
{{#if [notifications.connect.project.phase.update.scope]}}
Scope of the phase <strong>{{updatedPhase.name}}</strong> updated
{{/if}}
{{#if [notifications.connect.project.phase.milestone.transition.active]}}
{{#if [connect.action.project.product.update.spec]}}
Scope of the phase <strong>{{updatedPhase.name}}</strong> updated
{{/if}}
{{#if [connect.action.timeline.milestone.transition.active]}}
A milestone is activated in phase <strong>{{updatedPhase.name}}</strong>
{{/if}}
{{#if [notifications.connect.project.phase.milestone.transition.completed]}}
{{#if [connect.action.timeline.milestone.transition.completed]}}
A milestone is completed in phase <strong>{{updatedPhase.name}}</strong>
{{/if}}
{{#if [notifications.connect.project.phase.milestone.waiting.customer]}}
{{#if [connect.action.timeline.milestone.waiting.customer]}}
We are waiting for your input at a milestone in the phase <strong>{{updatedPhase.name}}</strong>
{{/if}}
</td>
Expand Down Expand Up @@ -94,9 +97,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}/plan">
<table>
<tr><td align="center">View plan on Connect</td></tr>
</table>
View plan on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
4 changes: 1 addition & 3 deletions emails/src/partials/project-specification.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
<table>
<tr><td align="center">View project on Connect</td></tr>
</table>
View project on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
4 changes: 1 addition & 3 deletions emails/src/partials/project-status.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
<table>
<tr><td align="center">View project on Connect</td></tr>
</table>
View project on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
4 changes: 1 addition & 3 deletions emails/src/partials/project-team.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}">
<table>
<tr><td align="center">View project on Connect</td></tr>
</table>
View project on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
4 changes: 1 addition & 3 deletions emails/src/partials/topics_and_posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@
<td class="empty-child-one"></td>
<td class="second-child" align="center">
<a href="{{@root.connectURL}}/projects/{{notifications.[0].projectId}}#feed-{{notifications.[0].topicId}}">
<table>
<tr><td align="center">View post on Connect</td></tr>
</table>
View post on Connect
</a>
</td>
<td class="empty-child-one"></td>
Expand Down
26 changes: 6 additions & 20 deletions emails/src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,16 @@ table.container, table.footer-container {
background-color: #0681FF;
height: 30px; }
.button-row .main-child .second-child a {
height: 30px;
border-radius: 4px;
text-align: center;
text-decoration: none;
display: block;
background-color: #0681FF; }
.button-row .main-child .second-child a table {
background-color: #0681FF;
border-radius: 4px;
height: 30px; }
.button-row .main-child .second-child a table td {
height: 30px;
background-color: #0681FF;
border-radius: 4px;
vertical-align: middle;
text-align: center;
color: #FFFFFF;
font-size: 13px; }
background-color: #0681FF;
padding-top: 6px;
padding-bottom: 5px;
text-align: center;
color: #FFFFFF;
font-size: 13px; }

.button-one .main-child .empty-child-one, .button-three .main-child .empty-child-one {
width: 216px; }
Expand All @@ -236,8 +228,6 @@ table.container, table.footer-container {
width: 167px; }
.button-one .main-child .second-child a, .button-three .main-child .second-child a {
width: 167px; }
.button-one .main-child .second-child a table td, .button-three .main-child .second-child a table td {
width: 167px; }

.button-two .main-child .empty-child-one {
width: 211px; }
Expand All @@ -246,8 +236,6 @@ table.container, table.footer-container {
width: 178px; }
.button-two .main-child .second-child a {
width: 178px; }
.button-two .main-child .second-child a table td {
width: 178px; }

.button-four .main-child .empty-child-one {
width: 210px; }
Expand All @@ -256,8 +244,6 @@ table.container, table.footer-container {
width: 180px; }
.button-four .main-child .second-child a {
width: 180px; }
.button-four .main-child .second-child a table td {
width: 180px; }

.copy-link {
height: 20px; }
Expand Down
Loading