From 9ff4903b08a51a4cbcf017875149793b8fc8effc Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Tue, 2 Jan 2018 12:39:41 +0530 Subject: [PATCH 1/3] =?UTF-8?q?Github=20issue#1566,=20Remove=20system=20ac?= =?UTF-8?q?tivity=20posts=20on=20dashboard=20for=20notifications=20launch?= =?UTF-8?q?=20=E2=80=94=20Disabled=20the=20member=20events=20notifications?= =?UTF-8?q?=20for=20discourse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/constants.js | 7 ++++++ src/handlers/memberEvents.js | 31 +++++++++++++---------- src/test/app.test.js | 48 ++++++------------------------------ 3 files changed, 33 insertions(+), 53 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index e9905ae..9be072b 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -189,30 +189,37 @@ module.exports = { added: { title: 'A new team member has joined your project', content: data => `${data.firstName} ${data.lastName} has joined project ${data.projectName}. Welcome ${data.firstName}! Looking forward to working with you.`, + disabled: true, }, managerJoined: { title: 'A Topcoder project manager has joined your project', content: data => `${data.firstName} ${data.lastName} has joined your project ${data.projectName} as a project manager.`, + disabled: true, }, copilotJoined: { title: 'A Topcoder copilot has joined your project', content: data => `${data.firstName} ${data.lastName} has joined your project ${data.projectName} as a copilot.`, + disabled: true, }, left: { title: 'A team member has left your project', content: data => `${data.firstName} ${data.lastName} has left project ${data.projectName}. Thanks for all your work ${data.firstName}.`, + disabled: true, }, removed: { title: 'A team member has left your project', content: data => `${data.firstName} ${data.lastName} has left project ${data.projectName}. Thanks for all your work ${data.firstName}.`, + disabled: true, }, ownerChanged: { title: 'Your project has a new owner', content: data => `${data.firstName} ${data.lastName} is now responsible for project ${data.projectName}. Good luck ${data.firstName}.`, + disabled: true, }, ownerAdded: { title: 'Ownership changed', content: data => `Your project has a new owner. ${data.firstName} ${data.lastName} is now responsible for project ${data.projectName}. Good luck ${data.firstName}!`, + disabled: true, }, }, }, diff --git a/src/handlers/memberEvents.js b/src/handlers/memberEvents.js index e5ec2dc..4654c86 100644 --- a/src/handlers/memberEvents.js +++ b/src/handlers/memberEvents.js @@ -59,11 +59,13 @@ function* memberAdded(logger, data) { lastName: addedMember.lastName, }; - notifications.discourse = [{ - projectId: project.id, - title: topic.title, - content: topic.content(topicData), - }]; + if (topic && !topic.disabled) { + notifications.discourse = [{ + projectId: project.id, + title: topic.title, + content: topic.content(topicData), + }]; + } return notifications; } @@ -79,6 +81,7 @@ function* memberRemoved(logger, data) { ]; let topic; + const notifications = {}; if (data.updatedBy === data.userId) { // Left topic = constants.notifications.discourse.teamMembers.left; @@ -93,13 +96,13 @@ function* memberRemoved(logger, data) { lastName: removedMember.lastName, }; - const notifications = { - discourse: [{ + if (topic && !topic.disabled) { + notifications.discourse = [{ projectId: project.id, title: topic.title, content: topic.content(topicData), - }], - }; + }]; + } return notifications; } @@ -119,6 +122,8 @@ function* memberUpdated(logger, data) { ]; const topic = constants.notifications.discourse.teamMembers.ownerChanged; + + const notifications = {}; const topicData = { projectName: project.name, projectUrl: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${project.id}/`, @@ -126,13 +131,13 @@ function* memberUpdated(logger, data) { lastName: updatedMember.lastName, }; - const notifications = { - discourse: [{ + if (topic && !topic.disabled) { + notifications.discourse = [{ projectId: project.id, title: topic.title, content: topic.content(topicData), - }], - }; + }]; + } return notifications; } diff --git a/src/test/app.test.js b/src/test/app.test.js index fec3579..fff9a5d 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -345,11 +345,7 @@ describe('app', () => { it('should create `Project.Member.ownerAdded` notification', (done) => { sendTestEvent(sampleEvents.memberAddedOwner, 'project.member.added'); setTimeout(() => { - const expectedTitle = 'Ownership changed'; - const expectedBody = 'Your project has a new owner. F_user L_user is now responsible for project Project name 1. Good luck F_user!'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -357,11 +353,7 @@ describe('app', () => { it('should create `Project.Member.TeamMemberAdded` notification', (done) => { sendTestEvent(sampleEvents.memberAddedTeamMember, 'project.member.added'); setTimeout(() => { - const expectedTitle = 'A new team member has joined your project'; - const expectedBody = 'F_user L_user has joined project Project name 1. Welcome F_user! Looking forward to working with you.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -369,11 +361,7 @@ describe('app', () => { it('should create `Project.Member.ManagerJoined` notification', (done) => { sendTestEvent(sampleEvents.memberAddedManager, 'project.member.added'); setTimeout(() => { - const expectedTitle = 'A Topcoder project manager has joined your project'; - const expectedBody = 'F_user L_user has joined your project Project name 1 as a project manager.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -381,11 +369,7 @@ describe('app', () => { it('should create `Project.Member.CopilotJoined` notification', (done) => { sendTestEvent(sampleEvents.memberAddedCopilot, 'project.member.added'); setTimeout(() => { - const expectedTitle = 'A Topcoder copilot has joined your project'; - const expectedBody = 'F_user L_user has joined your project Project name 1 as a copilot.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -399,11 +383,7 @@ describe('app', () => { sendTestEvent(sampleEvents.memberAddedCopilot, 'project.member.added'); setTimeout(() => { - const expectedTitle = 'A Topcoder copilot has joined your project'; - const expectedBody = 'F_user L_user has joined your project test as a copilot.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); const slackParams = slackSpy.lastCall.args; const expectedTestCopilotNotificaton = _.cloneDeep(expectedClaimedSlackCopilotNotification); _.extend(expectedTestCopilotNotificaton.attachments[0], { @@ -421,11 +401,7 @@ describe('app', () => { it('should create `Project.Member.Left` notification', (done) => { sendTestEvent(sampleEvents.memberRemovedLeft, 'project.member.removed'); setTimeout(() => { - const expectedTitle = 'A team member has left your project'; - const expectedBody = 'F_user L_user has left project Project name 1. Thanks for all your work F_user.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -433,11 +409,7 @@ describe('app', () => { it('should create `Project.Member.Removed` notification', (done) => { sendTestEvent(sampleEvents.memberRemovedRemoved, 'project.member.removed'); setTimeout(() => { - const expectedTitle = 'A team member has left your project'; - const expectedBody = 'F_user L_user has left project Project name 1. Thanks for all your work F_user.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); @@ -447,11 +419,7 @@ describe('app', () => { it('should create `Project.OwnerChanged` notification', (done) => { sendTestEvent(sampleEvents.memberUpdated, 'project.member.updated'); setTimeout(() => { - const expectedTitle = 'Your project has a new owner'; - const expectedBody = 'F_user L_user is now responsible for project Project name 1. Good luck F_user.'; - const params = spy.lastCall.args; - assert.equal(params[2], expectedTitle); - assert.equal(params[3], expectedBody); + sinon.assert.notCalled(spy); done(); }, testTimeout); }); From 82a4353e68c3b42570c4dd8bdbad2fcfe3df5763 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Tue, 2 Jan 2018 12:40:13 +0530 Subject: [PATCH 2/3] Temp deployment to dev env --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 8503cee..f999bf8 100644 --- a/circle.yml +++ b/circle.yml @@ -29,7 +29,7 @@ test: deployment: development: - branch: dev + branch: [dev, 'feature/slient-project-team-activity'] owner: topcoder-platform commands: - docker build -t $DEV_AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_REPOSITORY:$CIRCLE_SHA1 . From 4973d2e30af8ca9d3d6c888ac3857f899f66ba23 Mon Sep 17 00:00:00 2001 From: Vikas Agarwal Date: Tue, 2 Jan 2018 14:30:00 +0530 Subject: [PATCH 3/3] reverted temp deployment. --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index f999bf8..8503cee 100644 --- a/circle.yml +++ b/circle.yml @@ -29,7 +29,7 @@ test: deployment: development: - branch: [dev, 'feature/slient-project-team-activity'] + branch: dev owner: topcoder-platform commands: - docker build -t $DEV_AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_REPOSITORY:$CIRCLE_SHA1 .