diff --git a/src/resources/dataUseRegister/dataUseRegister.controller.js b/src/resources/dataUseRegister/dataUseRegister.controller.js index f2074714..87c52a6e 100644 --- a/src/resources/dataUseRegister/dataUseRegister.controller.js +++ b/src/resources/dataUseRegister/dataUseRegister.controller.js @@ -371,13 +371,20 @@ export default class DataUseRegisterController extends Controller { switch (type) { case constants.dataUseRegisterNotifications.DATAUSEAPPROVED: { + let teamEmailNotification = []; const adminTeam = await TeamModel.findOne({ type: 'admin' }) .populate({ path: 'users', }) .lean(); + const team = await TeamModel.findById(dataUseRegister.publisher.toString()); + if (team.notifications.length > 0 && team.notifications[0].optIn) { + team.notifications[0].subscribedEmails.map(teamEmail => { + teamEmailNotification.push({email: teamEmail}); + }); + } const dataUseTeamMembers = teamController.getTeamMembersByRole(adminTeam, constants.roleTypes.ADMIN_DATA_USE); - const emailRecipients = [...dataUseTeamMembers, uploader]; + const emailRecipients = [...dataUseTeamMembers, uploader, ...teamEmailNotification]; const options = { id,