diff --git a/Chart.yaml b/Chart.yaml index 2cf6e8a9..1ef06e2b 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1 +1 @@ -v5.0.5 +v5.0.6 diff --git a/src/resources/message/message.controller.js b/src/resources/message/message.controller.js index d5730a78..c210382c 100644 --- a/src/resources/message/message.controller.js +++ b/src/resources/message/message.controller.js @@ -131,16 +131,25 @@ module.exports = { [constants.teamNotificationTypes.DATAACCESSREQUEST] ); if (!_.isEmpty(subscribedMembersByType)) { + // build cleaner array of memberIds from subscribedMembersByType if (topicObj.topicMessages !== undefined) { - const memberIds = [...subscribedMembersByType.map(m => m.memberid.toString()), ...topicObj.createdBy._id.toString()]; + const memberIds = [...subscribedMembersByType.map(m => { + if (m.roles.includes('custodian.dar.manager')) { + return m.memberid.toString(); + } + }), ...topicObj.createdBy._id.toString()].filter(elem => elem); // returns array of objects [{email: 'email@email.com '}] for members in subscribed emails users is list of full user object const { memberEmails } = teamController.getMemberDetails([...memberIds], [...messageRecipients]); messageRecipients = [...teamNotificationEmails, ...memberEmails]; } else { - const memberIds = [...subscribedMembersByType.map(m => m.memberid.toString())].filter( + const memberIds = [...subscribedMembersByType.map(m => { + if (m.roles.includes('custodian.dar.manager')) { + return m.memberid.toString(); + } + })].filter( ele => ele !== topicObj.createdBy.toString() - ); + ).filter(elem => elem); const creatorObjectId = topicObj.createdBy.toString(); // returns array of objects [{email: 'email@email.com '}] for members in subscribed emails users is list of full user object const { memberEmails } = teamController.getMemberDetails([...memberIds], [...messageRecipients]);