From dcf6024fc238ce95de3998952620080ff44e503b Mon Sep 17 00:00:00 2001 From: Uttpal Date: Wed, 8 Feb 2017 19:58:20 +0530 Subject: [PATCH 1/7] fix #62 --- src/common/constants.js | 16 +++++++++++++++- src/handlers/projectEvents.js | 6 +++--- src/handlers/util.js | 2 +- src/test/app.test.js | 10 ++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index 4633ff1..c59d1c9 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -48,6 +48,7 @@ module.exports = { }, projectUnclaimed: (data) => { return { + icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-the-bot/85ae574c0c7063ef.png', channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, pretext: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', fallback: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', @@ -57,7 +58,20 @@ module.exports = { ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, fields: [] } - } + }, + projectUnclaimedReposted: (data) => { + return { + icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-error/cd2633216e7fd385.png', + channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, + pretext: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', + fallback: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', + title: _.get(data, 'project.name', ''), + title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, + text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, + fields: [] + } + }, }, discourse: { project: { diff --git a/src/handlers/projectEvents.js b/src/handlers/projectEvents.js index 6e65c1d..b7ffbf6 100644 --- a/src/handlers/projectEvents.js +++ b/src/handlers/projectEvents.js @@ -129,9 +129,9 @@ function* projectUnclaimedNotifications(logger, data) { projectCopilotIds.length === 0) { notifications.delayed = data; const slackNotification = util.buildSlackNotification( - { project, }, - constants.notifications.slack.projectUnclaimed - ) + { project }, + constants.notifications.slack.projectUnclaimedReposted + ); notifications.slack.copilot.push(slackNotification); } return notifications; diff --git a/src/handlers/util.js b/src/handlers/util.js index bb2b8df..c992503 100644 --- a/src/handlers/util.js +++ b/src/handlers/util.js @@ -200,7 +200,7 @@ function buildSlackNotification(data, slackDataGenerator) { const slackData = slackDataGenerator(data); return { username: config.get('SLACK_USERNAME'), - icon_url: config.get('SLACK_ICON_URL'), + icon_url: slackData.url || config.get('SLACK_ICON_URL'), channel: slackData.channel, attachments: [{ color: "#36a64f", diff --git a/src/test/app.test.js b/src/test/app.test.js index d4f503c..04da59d 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -66,7 +66,13 @@ const expectedSlackCopilotNotification = _.cloneDeep(expectedSlackNotficationBas _.extend(expectedSlackCopilotNotification.attachments[0], { pretext: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', fallback: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', -}) +}); + +const expectedRepostedSlackCopilotNotification = _.cloneDeep(expectedSlackNotficationBase); +_.extend(expectedRepostedSlackCopilotNotification.attachments[0], { + pretext: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', + fallback: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', +}); const expectedManagerSlackNotification = _.cloneDeep(expectedSlackNotficationBase); _.extend(expectedManagerSlackNotification.attachments[0], { @@ -278,7 +284,7 @@ describe('app', () => { assertCount += 1; sinon.assert.notCalled(spy); const params = slackSpy.lastCall.args; - assert.deepEqual(params[1], expectedSlackCopilotNotification); + assert.deepEqual(params[1], expectedRepostedSlackCopilotNotification); // console.log('assert#', assertCount) // console.log('callbackCount#', callbackCount) // checkAssert(assertCount, callbackCount, done); From 80e2534e7f48f55b956848499583df812d7ebda6 Mon Sep 17 00:00:00 2001 From: Uttpal Date: Wed, 8 Feb 2017 20:32:40 +0530 Subject: [PATCH 2/7] fix #62 --- src/common/constants.js | 13 +++++++++++++ src/handlers/memberEvents.js | 26 +++++++++++++++++++------- src/test/app.test.js | 10 ++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index c59d1c9..a10519a 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -72,6 +72,19 @@ module.exports = { fields: [] } }, + projectClaimed: (data) => { + return { + icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-grinning/a3b7f3fe9e838377.png', + channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, + pretext: `${data.firstName} ${data.lastName} has claimed a project. Welcome to the team!`, + fallback: `${data.firstName} ${data.lastName} has claimed a project. Welcome to the team!`, + title: _.get(data, 'project.name', ''), + title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, + text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, + fields: [] + } + }, }, discourse: { project: { diff --git a/src/handlers/memberEvents.js b/src/handlers/memberEvents.js index 234eee0..807f1dc 100644 --- a/src/handlers/memberEvents.js +++ b/src/handlers/memberEvents.js @@ -23,12 +23,26 @@ function* memberAdded(logger, data) { ]; let topic; + const notifications = { + slack: { + copilot: [], + }, + }; + if (data.role === constants.memberRoles.customer) { topic = constants.notifications.discourse.teamMembers.added; } else if (data.role === constants.memberRoles.manager) { topic = constants.notifications.discourse.teamMembers.managerJoined; } else if (data.role === constants.memberRoles.copilot) { topic = constants.notifications.discourse.teamMembers.copilotJoined; + // Notify project claimed + const slackNotification = util.buildSlackNotification( + { project, + firstName: addedMember.firstName, + lastName: addedMember.lastName, + }, + constants.notifications.slack.projectClaimed); + notifications.slack.copilot.push(slackNotification); } const topicData = { @@ -38,13 +52,11 @@ function* memberAdded(logger, data) { lastName: addedMember.lastName, }; - const notifications = { - discourse: [{ - projectId: project.id, - title: topic.title, - content: topic.content(topicData), - }], - }; + 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 04da59d..3f8926d 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -73,6 +73,14 @@ _.extend(expectedRepostedSlackCopilotNotification.attachments[0], { pretext: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', fallback: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', }); +const expectedClaimedSlackCopilotNotification = _.cloneDeep(expectedSlackNotficationBase); +_.extend(expectedClaimedSlackCopilotNotification.attachments[0], { + pretext: 'F_user L_user has claimed a project. Welcome to the team!', + fallback: 'F_user L_user has claimed a project. Welcome to the team!', + text: 'Project description 1', + title: 'Project name 1', + ts: '1477671612', +}); const expectedManagerSlackNotification = _.cloneDeep(expectedSlackNotficationBase); _.extend(expectedManagerSlackNotification.attachments[0], { @@ -354,6 +362,8 @@ describe('app', () => { const params = spy.lastCall.args; assert.equal(params[2], expectedTitle); assert.equal(params[3], expectedBody); + const slackParams = slackSpy.lastCall.args; + assert.deepEqual(slackParams[1], expectedClaimedSlackCopilotNotification); done(); }, testTimeout); }); From affcad64d58f4055e870e663696a2b94bbaa1057 Mon Sep 17 00:00:00 2001 From: Uttpal Date: Wed, 8 Feb 2017 20:43:54 +0530 Subject: [PATCH 3/7] fix #63 --- src/common/constants.js | 39 +++++++++++++++++++++++++++++++-------- src/test/app.test.js | 13 ++++++++++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index a10519a..42648e1 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -30,7 +30,7 @@ module.exports = { fallback: 'A project is ready to be reviewed.', title: _.get(data, 'project.name', ''), title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, - text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + text: _.truncate(_.get(data, 'project.description', ''), { length: 200, separator: /,? +.,/ }), ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, fields: [ { @@ -40,7 +40,12 @@ module.exports = { }, { title: 'Owner', - value: `${_.get(data, 'owner.firstName', '')} ${_.get(data, 'owner.lastName', '')}` , + value: `${_.get(data, 'owner.firstName', '')} ${_.get(data, 'owner.lastName', '')}`, + short: false, + }, + { + title: 'Project Type', + value: data.project.type, short: false, }, ], @@ -54,9 +59,15 @@ module.exports = { fallback: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', title: _.get(data, 'project.name', ''), title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, - text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + text: _.truncate(_.get(data, 'project.description', ''), { length: 200, separator: /,? +.,/ }), ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, - fields: [] + fields: [ + { + title: 'Project Type', + value: data.project.type, + short: false, + }, + ] } }, projectUnclaimedReposted: (data) => { @@ -67,9 +78,15 @@ module.exports = { fallback: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', title: _.get(data, 'project.name', ''), title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, - text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + text: _.truncate(_.get(data, 'project.description', ''), { length: 200, separator: /,? +.,/ }), ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, - fields: [] + fields: [ + { + title: 'Project Type', + value: data.project.type, + short: false, + }, + ] } }, projectClaimed: (data) => { @@ -80,9 +97,15 @@ module.exports = { fallback: `${data.firstName} ${data.lastName} has claimed a project. Welcome to the team!`, title: _.get(data, 'project.name', ''), title_link: `https://connect.${config.get('AUTH_DOMAIN')}/projects/${data.project.id}/`, - text: _.truncate(_.get(data, 'project.description', ''), {length: 200, separator: /,? +.,/ }), + text: _.truncate(_.get(data, 'project.description', ''), { length: 200, separator: /,? +.,/ }), ts: (new Date(_.get(data, 'project.updatedAt', null))).getTime() / 1000, - fields: [] + fields: [ + { + title: 'Project Type', + value: data.project.type, + short: false, + }, + ] } }, }, diff --git a/src/test/app.test.js b/src/test/app.test.js index 3f8926d..ea7eeca 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -55,7 +55,13 @@ const expectedSlackNotficationBase = { title: "test", title_link: "https://connect.topcoder-dev.com/projects/1/", text: "test", - fields: [], + fields: [ + { + short: false, + title: 'Project Type', + value: 'visual_design', + }, + ], footer: "Topcoder", footer_icon: "https://emoji.slack-edge.com/T03R80JP7/topcoder/7c68acd90a6b6d77.png", ts: 1478304000, @@ -89,6 +95,11 @@ _.extend(expectedManagerSlackNotification.attachments[0], { fields: [ { title: 'Ref Code', value: '', short: false }, { title: 'Owner', value: 'F_user L_user', short: false }, + { + short: false, + title: 'Project Type', + value: 'visual_design', + }, ] }) From 8f3e409cde57ad715ffdf0470f9fbdc1e000ed47 Mon Sep 17 00:00:00 2001 From: Uttpal Date: Wed, 8 Feb 2017 23:16:27 +0530 Subject: [PATCH 4/7] fix #45 --- src/common/constants.js | 4 ++++ src/handlers/memberEvents.js | 9 ++++++--- src/test/app.test.js | 13 +++++++++++++ src/test/data/events.memberAdded.owner.json | 11 +++++++++++ src/test/data/events.memberAdded.teamMember.json | 2 +- 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 src/test/data/events.memberAdded.owner.json diff --git a/src/common/constants.js b/src/common/constants.js index 42648e1..96ecf92 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -157,6 +157,10 @@ module.exports = { title: 'Your project has a new owner', content: (data) => `${data.firstName} ${data.lastName} is now responsible for project ${data.projectName}. Good luck ${data.firstName}.`, }, + ownerAdded: { + title: 'Ownership changed', + content: (data) => `Your project has a new owner ${data.firstName} ${data.lastName} is now responsible for project Project title. Good luck ${data.firstName}!`, + }, }, }, project: { diff --git a/src/handlers/memberEvents.js b/src/handlers/memberEvents.js index 807f1dc..9a1465d 100644 --- a/src/handlers/memberEvents.js +++ b/src/handlers/memberEvents.js @@ -10,6 +10,7 @@ const config = require('config'); const constants = require('../common/constants'); const util = require('./util'); +const _ = require('lodash'); /** * Create notifications from project.member.added events @@ -28,8 +29,9 @@ function* memberAdded(logger, data) { copilot: [], }, }; - - if (data.role === constants.memberRoles.customer) { + if (data.role === constants.memberRoles.customer && data.isPrimary) { + topic = constants.notifications.discourse.teamMembers.ownerAdded; + } else if (data.role === constants.memberRoles.customer) { topic = constants.notifications.discourse.teamMembers.added; } else if (data.role === constants.memberRoles.manager) { topic = constants.notifications.discourse.teamMembers.managerJoined; @@ -37,7 +39,8 @@ function* memberAdded(logger, data) { topic = constants.notifications.discourse.teamMembers.copilotJoined; // Notify project claimed const slackNotification = util.buildSlackNotification( - { project, + { + project, firstName: addedMember.firstName, lastName: addedMember.lastName, }, diff --git a/src/test/app.test.js b/src/test/app.test.js index ea7eeca..33f9cd5 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -27,6 +27,7 @@ const sampleEvents = { updatedReviewedAnotherStatus: require('./data/events.updated.reviewed.anotherStatus.json'), updatedReviewedSameStatus: require('./data/events.updated.reviewed.sameStatus.json'), memberAddedTeamMember: require('./data/events.memberAdded.teamMember.json'), + memberAddedOwner: require('./data/events.memberAdded.owner.json'), memberAddedManager: require('./data/events.memberAdded.manager.json'), memberAddedCopilot: require('./data/events.memberAdded.copilot.json'), memberRemovedLeft: require('./data/events.memberRemoved.left.json'), @@ -341,6 +342,18 @@ describe('app', () => { }); describe('`project.member.added` event', () => { + 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 title. Good luck F_user!'; + const params = spy.lastCall.args; + assert.equal(params[2], expectedTitle); + assert.equal(params[3], expectedBody); + done(); + }, testTimeout); + }); + it('should create `Project.Member.TeamMemberAdded` notification', (done) => { sendTestEvent(sampleEvents.memberAddedTeamMember, 'project.member.added'); setTimeout(() => { diff --git a/src/test/data/events.memberAdded.owner.json b/src/test/data/events.memberAdded.owner.json new file mode 100644 index 0000000..e57eb32 --- /dev/null +++ b/src/test/data/events.memberAdded.owner.json @@ -0,0 +1,11 @@ +{ + "id": 1185, + "userId": 40051331, + "role": "customer", + "isPrimary": true, + "createdAt": "2016-11-04T03:57:57.000Z", + "updatedAt": "2016-11-04T03:57:57.000Z", + "createdBy": 40152856, + "updatedBy": 40152856, + "projectId": 1 +} diff --git a/src/test/data/events.memberAdded.teamMember.json b/src/test/data/events.memberAdded.teamMember.json index e57eb32..c5c3085 100644 --- a/src/test/data/events.memberAdded.teamMember.json +++ b/src/test/data/events.memberAdded.teamMember.json @@ -2,7 +2,7 @@ "id": 1185, "userId": 40051331, "role": "customer", - "isPrimary": true, + "isPrimary": false, "createdAt": "2016-11-04T03:57:57.000Z", "updatedAt": "2016-11-04T03:57:57.000Z", "createdBy": 40152856, From ec1ca3287adc7fe5f4e3a4be1fa00511e56de959 Mon Sep 17 00:00:00 2001 From: Uttpal Date: Thu, 9 Feb 2017 00:10:39 +0530 Subject: [PATCH 5/7] fixed #62 bugs --- src/handlers/memberEvents.js | 20 ++++++++++++-------- src/test/app.test.js | 26 +++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/handlers/memberEvents.js b/src/handlers/memberEvents.js index 9a1465d..e5ec2dc 100644 --- a/src/handlers/memberEvents.js +++ b/src/handlers/memberEvents.js @@ -38,14 +38,18 @@ function* memberAdded(logger, data) { } else if (data.role === constants.memberRoles.copilot) { topic = constants.notifications.discourse.teamMembers.copilotJoined; // Notify project claimed - const slackNotification = util.buildSlackNotification( - { - project, - firstName: addedMember.firstName, - lastName: addedMember.lastName, - }, - constants.notifications.slack.projectClaimed); - notifications.slack.copilot.push(slackNotification); + if ((project.status === constants.projectStatuses.active || + project.status === constants.projectStatuses.reviewed) + && _.filter(project.members, ['role', 'copilot']).length < 2) { + const slackNotification = util.buildSlackNotification( + { + project, + firstName: addedMember.firstName, + lastName: addedMember.lastName, + }, + constants.notifications.slack.projectClaimed); + notifications.slack.copilot.push(slackNotification); + } } const topicData = { diff --git a/src/test/app.test.js b/src/test/app.test.js index 33f9cd5..9a80353 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -386,8 +386,32 @@ describe('app', () => { const params = spy.lastCall.args; assert.equal(params[2], expectedTitle); assert.equal(params[3], expectedBody); + done(); + }, testTimeout); + }); + it('should create `Project.Member.CopilotJoined` notification and slack copilot joined notification', (done) => { + request.get.restore(); + stub = sinon.stub(request, 'get'); + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v4/projects/1`)) + .yields(null, { statusCode: 200 }, sampleProjects.projectTest); + stub.withArgs(sinon.match.has('url', `${config.API_BASE_URL}/v3/members/_search/?query=userId:40051331`)) + .yields(null, { statusCode: 200 }, sampleUsers.user1); + + 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); const slackParams = slackSpy.lastCall.args; - assert.deepEqual(slackParams[1], expectedClaimedSlackCopilotNotification); + const expectedTestCopilotNotificaton = _.cloneDeep(expectedClaimedSlackCopilotNotification); + _.extend(expectedTestCopilotNotificaton.attachments[0], { + text: 'test', + title: 'test', + ts: 1478304000, + }); + assert.deepEqual(slackParams[1], expectedTestCopilotNotificaton); done(); }, testTimeout); }); From 7593ab2ed41ebc3ac5f244bb04214dc2ba82507d Mon Sep 17 00:00:00 2001 From: Uttpal Date: Thu, 9 Feb 2017 00:23:15 +0530 Subject: [PATCH 6/7] map product_types to name --- src/common/constants.js | 15 +++++++++++---- src/test/app.test.js | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index 96ecf92..df5fcdb 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -10,6 +10,12 @@ const _ = require('lodash'); const config = require('config'); +const projectTypes = { + app_dev: 'Full App', + generic: 'Work Project', + visual_prototype: 'Design & Prototype', + visual_design: 'Design', +}; module.exports = { // The event types to be consumed from the source RabbitMQ events: { @@ -45,7 +51,7 @@ module.exports = { }, { title: 'Project Type', - value: data.project.type, + value: projectTypes[data.project.type], short: false, }, ], @@ -64,7 +70,7 @@ module.exports = { fields: [ { title: 'Project Type', - value: data.project.type, + value: projectTypes[data.project.type], short: false, }, ] @@ -83,7 +89,7 @@ module.exports = { fields: [ { title: 'Project Type', - value: data.project.type, + value: projectTypes[data.project.type], short: false, }, ] @@ -102,7 +108,7 @@ module.exports = { fields: [ { title: 'Project Type', - value: data.project.type, + value: projectTypes[data.project.type], short: false, }, ] @@ -187,6 +193,7 @@ module.exports = { canceled: 'cancelled', // spelling is not a type :) completed: 'completed', }, + projectTypes, memberRoles: { manager: 'manager', customer: 'customer', diff --git a/src/test/app.test.js b/src/test/app.test.js index 9a80353..894e59a 100644 --- a/src/test/app.test.js +++ b/src/test/app.test.js @@ -60,7 +60,7 @@ const expectedSlackNotficationBase = { { short: false, title: 'Project Type', - value: 'visual_design', + value: 'Design', }, ], footer: "Topcoder", @@ -99,7 +99,7 @@ _.extend(expectedManagerSlackNotification.attachments[0], { { short: false, title: 'Project Type', - value: 'visual_design', + value: 'Design', }, ] }) From cc5ddeb89973f5f6c3c2c162e8a66e80061ca746 Mon Sep 17 00:00:00 2001 From: Uttpal Date: Thu, 9 Feb 2017 00:29:26 +0530 Subject: [PATCH 7/7] add slack icons to constants --- src/common/constants.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/constants.js b/src/common/constants.js index df5fcdb..9ad3e4f 100644 --- a/src/common/constants.js +++ b/src/common/constants.js @@ -16,6 +16,13 @@ const projectTypes = { visual_prototype: 'Design & Prototype', visual_design: 'Design', }; +const icons = { + slack: { + CoderBotIcon: 'https://emoji.slack-edge.com/T03R80JP7/coder-the-bot/85ae574c0c7063ef.png', + CoderErrorIcon: 'https://emoji.slack-edge.com/T03R80JP7/coder-error/cd2633216e7fd385.png', + CoderGrinningIcon: 'https://emoji.slack-edge.com/T03R80JP7/coder-grinning/a3b7f3fe9e838377.png', + }, +}; module.exports = { // The event types to be consumed from the source RabbitMQ events: { @@ -59,7 +66,7 @@ module.exports = { }, projectUnclaimed: (data) => { return { - icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-the-bot/85ae574c0c7063ef.png', + icon_url: icons.slack.CoderBotIcon, channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, pretext: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', fallback: 'A project has been reviewed and needs a copilot. Please check it out and claim it.', @@ -78,7 +85,7 @@ module.exports = { }, projectUnclaimedReposted: (data) => { return { - icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-error/cd2633216e7fd385.png', + icon_url: icons.slack.CoderErrorIcon, channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, pretext: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', fallback: 'We\'re still looking for a copilot for a reviewed project. Please check it out and claim it.', @@ -97,7 +104,7 @@ module.exports = { }, projectClaimed: (data) => { return { - icon_url: 'https://emoji.slack-edge.com/T03R80JP7/coder-grinning/a3b7f3fe9e838377.png', + icon_url: icons.slack.CoderGrinningIcon, channel: `${config.get('SLACK_CHANNEL_COPILOTS')}`, pretext: `${data.firstName} ${data.lastName} has claimed a project. Welcome to the team!`, fallback: `${data.firstName} ${data.lastName} has claimed a project. Welcome to the team!`, @@ -193,10 +200,11 @@ module.exports = { canceled: 'cancelled', // spelling is not a type :) completed: 'completed', }, - projectTypes, memberRoles: { manager: 'manager', customer: 'customer', copilot: 'copilot', }, + projectTypes, + icons, };