Skip to content

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

Merged
merged 4 commits into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -102,29 +102,29 @@ const getNotificationsForMentionedUser = (eventConfig, content) => {
};

/**
* Get notifications for users obtained from createdBy
* Get notifications for users obtained from originator
*
* @param {Object} eventConfig event configuration
* @param {String} createdBy created by
* @param {String} originator originator userId
*
* @return {Promise} resolves to a list of notifications
*/
const getNotificationsForCreatedBy = (eventConfig, createdBy) => {
const getNotificationsForOriginator = (eventConfig, originator) => {
// 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.'));
if (!originator) {
return Promise.reject(new Error('Missing originator in the event message.'));
}

return Promise.resolve([{
userId: createdBy.toString(),
userId: originator.toString(),
contents: {
creator: true,
originator: true,
},
}]);
};
Expand Down Expand Up @@ -335,7 +335,7 @@ const handler = (topic, message, logger, callback) => {
// - check that event has everything required or throw error
getNotificationsForTopicStarter(eventConfig, message.topicId),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gondzo we might reuse the logic of originator, which I mentioned in other comment, here to be generic enough to send notifications to the originator.

getNotificationsForUserId(eventConfig, message.userId),
getNotificationsForCreatedBy(eventConfig, message.createdBy),
getNotificationsForOriginator(eventConfig, message.originator),
getNotificationsForMentionedUser(eventConfig, message.postContent),
getProjectMembersNotifications(eventConfig, project),
getTopCoderMembersNotifications(eventConfig),
Expand Down
4 changes: 2 additions & 2 deletions connect/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module.exports = {
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',
COPILOT_REFUSED: 'notifications.connect.project.member.copilot.refused',
INVITE_APPROVED: 'notifications.connect.project.member.invite.approved',
INVITE_REJECTED: 'notifications.connect.project.member.invite.rejected',
},
PROJECT: {
ACTIVE: 'notifications.connect.project.active',
Expand Down
12 changes: 6 additions & 6 deletions connect/events-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ const EVENTS = [
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_REQUESTED,
topcoderRoles: [ROLE_CONNECT_COPILOT_MANAGER],
}, {
type: BUS_API_EVENT.CONNECT.MEMBER.COPILOT_ADDED,
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_APPROVED,
toUserHandle: true,
creator: true
originator: true
}, {
type: BUS_API_EVENT.CONNECT.MEMBER.COPILOT_REFUSED,
creator: true
type: BUS_API_EVENT.CONNECT.MEMBER.INVITE_REJECTED,
originator: true
},

// Project activity
Expand Down Expand Up @@ -276,8 +276,8 @@ const EVENT_BUNDLES = {
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,
BUS_API_EVENT.CONNECT.MEMBER.INVITE_APPROVED,
BUS_API_EVENT.CONNECT.MEMBER.INVITE_REJECTED,
],
},
PROJECT_PLAN: {
Expand Down
8 changes: 4 additions & 4 deletions emails/src/partials/project-team.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@
{{#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]}}
{{#if [notifications.connect.project.member.invite.approved]}}
{{#if [creator]}}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Your request to add invite the member 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 [notifications.connect.project.member.invite.rejected]}}
Your request to add the member was refused
{{/if}}
</td>
</tr>
Expand Down