-
Notifications
You must be signed in to change notification settings - Fork 15
Copilot workflow changes #89
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,34 @@ const getNotificationsForMentionedUser = (eventConfig, content) => { | |
}); | ||
}; | ||
|
||
/** | ||
* Get notifications for users obtained from createdBy | ||
* | ||
* @param {Object} eventConfig event configuration | ||
* @param {String} createdBy created by | ||
* | ||
* @return {Promise} resolves to a list of notifications | ||
*/ | ||
const getNotificationsForCreatedBy = (eventConfig, createdBy) => { | ||
// if event doesn't have to be notified to creator, just ignore | ||
if (!eventConfig.creator) { | ||
return Promise.resolve([]); | ||
} | ||
|
||
// if we have to send notification to the creator, | ||
// but it's not provided in the message, then throw error | ||
if (!createdBy) { | ||
return Promise.reject(new Error('Missing createdBy in the event message.')); | ||
} | ||
|
||
return Promise.resolve([{ | ||
userId: createdBy.toString(), | ||
contents: { | ||
creator: true, | ||
}, | ||
}]); | ||
}; | ||
|
||
/** | ||
* Get project members notifications | ||
* | ||
|
@@ -307,6 +335,7 @@ const handler = (topic, message, logger, callback) => { | |
// - check that event has everything required or throw error | ||
getNotificationsForTopicStarter(eventConfig, message.topicId), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gondzo we might reuse the logic of |
||
getNotificationsForUserId(eventConfig, message.userId), | ||
getNotificationsForCreatedBy(eventConfig, message.createdBy), | ||
getNotificationsForMentionedUser(eventConfig, message.postContent), | ||
getProjectMembersNotifications(eventConfig, project), | ||
getTopCoderMembersNotifications(eventConfig), | ||
|
@@ -321,7 +350,7 @@ const handler = (topic, message, logger, callback) => { | |
)).then((notifications) => { | ||
allNotifications = _.filter(notifications, notification => notification.userId !== `${message.initiatorUserId}`); | ||
|
||
if (eventConfig.includeUsers && message[eventConfig.includeUsers] && message[eventConfig.includeUsers].length>0){ | ||
if (eventConfig.includeUsers && message[eventConfig.includeUsers] && message[eventConfig.includeUsers].length > 0) { | ||
allNotifications = _.filter(allNotifications, notification => message[eventConfig.includeUsers].contains(notification.userId)); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,9 @@ module.exports = { | |
ASSIGNED_AS_OWNER: 'notifications.connect.project.member.assignedAsOwner', | ||
INVITE_CREATED: 'notifications.connect.project.member.invite.created', | ||
INVITE_UPDATED: 'notifications.connect.project.member.invite.updated', | ||
INVITE_REQUESTED: 'notifications.connect.project.member.invite.requested', | ||
COPILOT_ADDED: 'notifications.connect.project.member.copilot.added', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gondzo I would like to rename this event to |
||
COPILOT_REFUSED: 'notifications.connect.project.member.copilot.refused', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to rename this event to |
||
}, | ||
PROJECT: { | ||
ACTIVE: 'notifications.connect.project.active', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,14 @@ const PROJECT_ROLE_RULES = { | |
// TopCoder roles | ||
const ROLE_CONNECT_COPILOT = 'Connect Copilot'; | ||
const ROLE_CONNECT_MANAGER = 'Connect Manager'; | ||
const ROLE_CONNECT_COPILOT_MANAGER = 'Connect Copilot Manager'; | ||
const ROLE_ADMINISTRATOR = 'administrator'; | ||
|
||
// TopCoder role rules | ||
const TOPCODER_ROLE_RULES = { | ||
[ROLE_CONNECT_COPILOT]: { id: config.CONNECT_COPILOT_ROLE_ID }, | ||
[ROLE_CONNECT_MANAGER]: { id: config.CONNECT_MANAGER_ROLE_ID }, | ||
[ROLE_CONNECT_COPILOT_MANAGER]: { id: config.CONNECT_COPILOT_MANAGER_ROLE_ID }, | ||
[ROLE_ADMINISTRATOR]: { id: config.ADMINISTRATOR_ROLE_ID }, | ||
}; | ||
|
||
|
@@ -107,6 +109,16 @@ const EVENTS = [ | |
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_CREATED, | ||
projectRoles: [], | ||
toUserHandle: true, | ||
}, { | ||
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_REQUESTED, | ||
topcoderRoles: [ROLE_CONNECT_COPILOT_MANAGER], | ||
}, { | ||
type: BUS_API_EVENT.CONNECT.MEMBER.COPILOT_ADDED, | ||
toUserHandle: true, | ||
creator: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gondzo Can we have better naming for |
||
}, { | ||
type: BUS_API_EVENT.CONNECT.MEMBER.COPILOT_REFUSED, | ||
creator: true | ||
}, | ||
|
||
// Project activity | ||
|
@@ -149,7 +161,7 @@ const EVENTS = [ | |
type: BUS_API_EVENT.CONNECT.PROJECT.FILE_UPLOADED, | ||
version: 2, | ||
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER], | ||
includeUsers: 'allowedUsers' | ||
includeUsers: 'allowedUsers', | ||
}, { | ||
type: BUS_API_EVENT.CONNECT.PROJECT.SPECIFICATION_MODIFIED, | ||
version: 2, | ||
|
@@ -160,12 +172,12 @@ const EVENTS = [ | |
}, { | ||
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.MODIFIED, | ||
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER], | ||
includeUsers: 'allowedUsers' | ||
includeUsers: 'allowedUsers', | ||
}, { | ||
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PROGRESS_UPDATED, | ||
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER], | ||
}, | ||
|
||
// Phase activity | ||
{ | ||
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.PHASE_ACTIVATED, | ||
|
@@ -200,8 +212,8 @@ const EVENTS = [ | |
}, { | ||
type: BUS_API_EVENT.CONNECT.PROJECT_PLAN.TIMELINE_ADJUSTED, | ||
projectRoles: [PROJECT_ROLE_OWNER, PROJECT_ROLE_COPILOT, PROJECT_ROLE_MANAGER, PROJECT_ROLE_MEMBER], | ||
includeUsers: 'allowedUsers' | ||
} | ||
includeUsers: 'allowedUsers', | ||
}, | ||
]; | ||
|
||
const EVENT_BUNDLES = { | ||
|
@@ -263,6 +275,9 @@ const EVENT_BUNDLES = { | |
BUS_API_EVENT.CONNECT.MEMBER.MANAGER_JOINED, | ||
BUS_API_EVENT.CONNECT.MEMBER.REMOVED, | ||
BUS_API_EVENT.CONNECT.MEMBER.INVITE_CREATED, | ||
BUS_API_EVENT.CONNECT.MEMBER.INVITE_REQUESTED, | ||
BUS_API_EVENT.CONNECT.MEMBER.COPILOT_ADDED, | ||
BUS_API_EVENT.CONNECT.MEMBER.COPILOT_REFUSED, | ||
], | ||
}, | ||
PROJECT_PLAN: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ | |
<td class="main-td"> | ||
<table class="main-child"> | ||
<tr><td></td></tr> | ||
</table> | ||
</table> | ||
</td> | ||
</tr> | ||
|
||
|
@@ -60,12 +60,25 @@ | |
{{#if [notifications.connect.project.member.invite.created]}} | ||
Hi <strong>{{userFullName}}</strong>, you are invited to join the project {{projectName}}. Please click on the button ("View project on Connect") below to join. | ||
{{/if}} | ||
{{#if [notifications.connect.project.member.invite.requested]}} | ||
You are requested to add <strong>{{userFullName}}</strong> as a copilot | ||
{{/if}} | ||
{{#if [notifications.connect.project.member.copilot.added]}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for keep track of, this would be updated as per event rename suggested above. |
||
{{#if [creator]}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gondzo I think we need to rename this creator as well, need not we ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is done already @RishiRajSahu |
||
Your request to add invite the copilot was approved | ||
{{else}} | ||
Hi <strong>{{userFullName}}</strong>, you are added as a copilot | ||
{{/if}} | ||
{{/if}} | ||
{{#if [notifications.connect.project.member.copilot.refused]}} | ||
Your request to add the copilot was refused | ||
{{/if}} | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</table> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
|
@@ -76,7 +89,7 @@ | |
<td class="main-td"> | ||
<table class="main-child"> | ||
<tr><td></td></tr> | ||
</table> | ||
</table> | ||
</td> | ||
</tr> | ||
<tr class="button-row button-one"> | ||
|
@@ -98,7 +111,7 @@ | |
<td class="main-td"> | ||
<table class="main-child"> | ||
<tr><td></td></tr> | ||
</table> | ||
</table> | ||
</td> | ||
</tr> | ||
{{/if}} | ||
{{/if}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gondzo I forgot how do we manage these ids when we test the application in dev env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just use what is set in the admin app - role ids should be consistent between dev and prod