Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Pushing welcome message copy change to production #101

Merged
merged 8 commits into from
Feb 6, 2019
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
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ defaults: &defaults
LOG_LEVEL: debug
AUTH_DOMAIN: topcoder-dev.com
AUTH_SECRET: secret
API_URL_PROJECTS: http://localhost:3001/v4/projects
API_URL_MEMBERS: http://localhost:3001/v3/members
API_URL_USERS: http://localhost:3001/v3/users
API_URL_AUTHORIZATIONS: http://localhost:3001/v3/authorizations
API_URL_TOPICS: http://localhost:3001/v5/topics

jobs:
test:
Expand All @@ -27,7 +32,7 @@ jobs:
command: |
echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list
wget -O- https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get update --fix-missing
sudo apt-get install rabbitmq-server
sudo service rabbitmq-server start
sudo cp local/rabbitmq_delayed_message_exchange-0.0.1.ez /usr/lib/rabbitmq/lib/rabbitmq_server-*/plugins
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ To override default settings please add them to a file `./config/local.js`:
- `RABBITMQ.DELAY_DURATION`: Amount of delay before reposting unclaimed project
- `RABBITMQ.NOTIFICATIONS_EXCHANGE_NAME`: the notification RabbitMQ's topic exchange name
- `LOGENTRIES_TOKEN`: the Logentries token generated from https://logentries.com/
- `API_BASE_URL`: the base url to the API server to get project/user info
- `API_URL_PROJECTS`: the projects service url
- `API_URL_MEMBERS`: `API_BASE_URL` the members service url
- `API_URL_USERS`: `API_BASE_URL` the users service url
- `API_URL_AUTHORIZATIONS`: `API_BASE_URL` the authorizations service url
- `API_URL_TOPICS`: `API_BASE_URL` the topics service url
- `DISABLE_DELAY_EXCHANGE`: Disable exchage type delay and use 'direct' instead(Note: after changing this delete existing delay exchange )
- `TC_SLACK_WEBHOOK_URL`: slack webhook url
- `SLACK_ICON_URL`: slack webhook icon url
Expand Down
8 changes: 6 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ module.exports = {
// Token is generated from https://logentries.com/
LOGENTRIES_TOKEN: '',

// The base url to the project/user API server
API_BASE_URL: 'http://localhost:3001',
// The different services used by this project
API_URL_PROJECTS: 'http://localhost:3001/v4/projects',
API_URL_MEMBERS: 'http://localhost:3001/v3/members',
API_URL_USERS: 'http://localhost:3001/v3/users',
API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations',
API_URL_TOPICS: 'http://localhost:3001/v5/topics',

// Disable delay exchange and use direct instead ( delete existing delay exchnge after changing)
DISABLE_DELAY_EXCHANGE: false,
Expand Down
6 changes: 5 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
"DELAYED_NOTIFICATIONS_EXCHANGE_NAME": "dev.connect-notifications-reminders"
},

"API_BASE_URL": "https://api.topcoder-dev.com"
"API_URL_PROJECTS": "http://api.topcoder-dev.com/v4/projects",
"API_URL_MEMBERS": "http://api.topcoder-dev.com/v3/members",
"API_URL_USERS": "http://api.topcoder-dev.com/v3/users",
"API_URL_AUTHORIZATIONS": "http://api.topcoder-dev.com/v3/authorizations",
"API_URL_TOPICS": "http://api.topcoder-dev.com/v5/topics"
}
6 changes: 5 additions & 1 deletion config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@
"SLACK_CHANNEL_COPILOTS": "#connect-copilots",
"SLACK_CHANNEL_NPS": "#customer-experience",

"API_BASE_URL": "https://api.topcoder.com"
"API_URL_PROJECTS": "http://api.topcoder.com/v4/projects",
"API_URL_MEMBERS": "http://api.topcoder.com/v3/members",
"API_URL_USERS": "http://api.topcoder.com/v3/users",
"API_URL_AUTHORIZATIONS": "http://api.topcoder.com/v3/authorizations",
"API_URL_TOPICS": "http://api.topcoder.com/v5/topics"
}
6 changes: 5 additions & 1 deletion config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ module.exports = {
DELAY_DURATION: 0,
},
TC_SLACK_WEBHOOK_URL: 'http://localhost:3001/slack',
API_BASE_URL: 'http://localhost:3001',
API_URL_PROJECTS: 'http://localhost:3001/v4/projects',
API_URL_MEMBERS: 'http://localhost:3001/v3/members',
API_URL_USERS: 'http://localhost:3001/v3/users',
API_URL_AUTHORIZATIONS: 'http://localhost:3001/v3/authorizations',
API_URL_TOPICS: 'http://localhost:3001/v5/topics',
AUTH0_URL: process.env.DEV_AUTH0_URL || '',
AUTH0_AUDIENCE: process.env.DEV_AUTH0_AUDIENCE || '',
TOKEN_CACHE_TIME: process.env.DEV_TOKEN_CACHE_TIME || 86400000,
Expand Down
27 changes: 26 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ make_task_def(){
{
"name": "AUTH0_PROXY_SERVER_URL",
"value": "%s"
},
{
"name": "API_URL_PROJECTS",
"value": "%s"
},
{
"name": "API_URL_MEMBERS",
"value": "%s"
},
{
"name": "API_URL_USERS",
"value": "%s"
},
{
"name": "API_URL_AUTHORIZATIONS",
"value": "%s"
},
{
"name": "API_URL_TOPICS",
"value": "%s"
}
],
"logConfiguration": {
Expand All @@ -108,14 +128,19 @@ make_task_def(){
AUTH0_CLIENT_ID=$(eval "echo \$${ENV}_AUTH0_CLIENT_ID")
AUTH0_CLIENT_SECRET=$(eval "echo \$${ENV}_AUTH0_CLIENT_SECRET")
AUTH0_PROXY_SERVER_URL=$(eval "echo \$${ENV}_AUTH0_PROXY_SERVER_URL")
API_URL_PROJECTS=$(eval "echo \$${ENV}_API_URL_PROJECTS")
API_URL_MEMBERS=$(eval "echo \$${ENV}_API_URL_MEMBERS")
API_URL_USERS=$(eval "echo \$${ENV}_API_URL_USERS")
API_URL_AUTHORIZATIONS=$(eval "echo \$${ENV}_API_URL_AUTHORIZATIONS")
API_URL_TOPICS=$(eval "echo \$${ENV}_API_URL_TOPICS")

if [ "$ENV" = "PROD" ]; then
NODE_ENV=production
elif [ "$ENV" = "DEV" ]; then
NODE_ENV=development
fi

task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
task_def=$(printf "$task_template" $ACCOUNT_ID $AWS_REGION $AWS_REPOSITORY $CIRCLE_SHA1 $NODE_ENV $LOG_LEVEL $CAPTURE_LOGS $LOGENTRIES_TOKEN $RABBITMQ_URL $TC_SLACK_WEBHOOK_URL "$AUTH0_URL" "$AUTH0_AUDIENCE" $AUTH0_CLIENT_ID "$AUTH0_CLIENT_SECRET" $TOKEN_CACHE_TIME "$AUTH0_PROXY_SERVER_URL" "$API_URL_PROJECTS" "$API_URL_MEMBERS" "$API_URL_USERS" "$API_URL_AUTHORIZATIONS" "$API_URL_TOPICS" $AWS_ECS_CLUSTER $AWS_REGION $NODE_ENV)
}

push_ecr_image(){
Expand Down
4 changes: 2 additions & 2 deletions src/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ module.exports = {
discourse: {
project: {
created: {
title: 'Your project has been created, and we\'re ready for your specification',
content: data => `Hello, Coder here! Your project '${data.projectName}' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the <a href="${data.projectUrl}scope/" rel="nofollow">Scope</a> section. Once you've finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.`,
title: 'Share requirements and submit your draft project for review.',
content: data => `Your project '${data.projectName}' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.`,
},
submittedForReview: {
title: 'Your project has been submitted for review',
Expand Down
6 changes: 3 additions & 3 deletions src/handlers/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const createProjectDiscourseNotification = Promise.coroutine(
return Promise.reject(new Error('Error retrieving system token'));
}
const options = {
url: `${config.get('API_BASE_URL')}/v5/topics/create`,
url: `${config.get('API_URL_TOPICS')}/create`,
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
Expand Down Expand Up @@ -138,7 +138,7 @@ function* getProjectById(id) {
return Promise.reject(new Error('Error retrieving system token'));
}
return yield requestPromise({
url: `${config.get('API_BASE_URL')}/v4/projects/${id}`,
url: `${config.get('API_URL_PROJECTS')}/${id}`,
headers: {
Authorization: `Bearer ${token}`,
},
Expand Down Expand Up @@ -179,7 +179,7 @@ function* getUserById(id) { // eslint-disable-line require-yield
}
return reject(new Error('user not found'));
};
return requestPromise({ url: `${config.get('API_BASE_URL')}/v3/members/_search/?query=userId:${id}` }, cb);
return requestPromise({ url: `${config.get('API_URL_MEMBERS')}/_search/?query=userId:${id}` }, cb);
}


Expand Down
20 changes: 10 additions & 10 deletions src/test/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,33 +216,33 @@ describe('app', () => {
// Stub the calls to API server
stub = sinon.stub(request, 'get');
const stubArgs = {
url: `${config.API_BASE_URL}/v4/projects/1`,
url: `${config.API_URL_PROJECTS}/1`,
};
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 200 }, sampleProjects.project1);

stubArgs.url = `${config.API_BASE_URL}/v4/projects/1000`;
stubArgs.url = `${config.API_URL_PROJECTS}/1000`;
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 404 });

stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:1`;
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:1`;
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 200 }, sampleUsers.user1);

stubArgs.url = `${config.API_BASE_URL}/v3/users/1000`;
stubArgs.url = `${config.API_URL_USERS}/1000`;
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 404 });

stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`;
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:40051331`;
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 200 }, sampleUsers.user1);

stubArgs.url = `${config.API_BASE_URL}/v3/members/_search/?query=userId:50051333`;
stubArgs.url = `${config.API_URL_MEMBERS}/_search/?query=userId:50051333`;
stub.withArgs(sinon.match.has('url', stubArgs.url))
.yields(null, { statusCode: 200 }, sampleUsers.user1);

postStub = sinon.stub(request, 'post');
postStub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/authorizations/`))
postStub.withArgs(sinon.match.has('url', `${config.API_URL_AUTHORIZATIONS}/`))
.yields(null, { statusCode: 200 }, sampleAuth);

postStub.withArgs(sinon.match.has('url', config.TC_SLACK_WEBHOOK_URL))
Expand Down Expand Up @@ -303,8 +303,8 @@ describe('app', () => {
it('should create `Project.Created` notification', (done) => {
sendTestEvent(sampleEvents.draftCreated, 'project.draft-created');
setTimeout(() => {
const expectedTitle = 'Your project has been created, and we\'re ready for your specification';
const expectedBody = 'Hello, Coder here! Your project \'test\' has been drafted. If you have your requirements documented, just verify it against our checklist and then upload it on the <a href="https://connect.topcoder-dev.com/projects/1/scope/" rel="nofollow">Scope</a> section. Once you\'ve finalized your scope, select the "Submit for Review" button. Topcoder will then review your drafted project and will assign a manager to get your delivery in-progress! Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.';
const expectedTitle = 'Share requirements and submit your draft project for review.';
const expectedBody = 'Your project \'test\' has been drafted. If you have requirements documented, share them for review under the Files or Links section. Once you’re ready, click the "Submit for Review" button. Topcoder will then review your drafted project and will get your project started! Get stuck or need help? Email us at <a href="mailto:support@topcoder.com?subject=Question%20Regarding%20My%20New%20Topcoder%20Connect%20Project" rel="nofollow">support@topcoder.com</a>.';
const params = spy.lastCall.args;
assert.equal(params[2], expectedTitle);
assert.equal(params[3], expectedBody);
Expand All @@ -319,7 +319,7 @@ describe('app', () => {
const callbackCount = 1;
request.get.restore();
stub = sinon.stub(request, 'get');
stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:8547900`))
stub.withArgs(sinon.match.has('url', `${config.API_URL_MEMBERS}/_search/?query=userId:8547900`))
.yields(null, { statusCode: 200 }, sampleUsers.user1);

sendTestEvent(sampleEvents.updatedInReview, 'project.updated');
Expand Down