Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhdruk authored Sep 16, 2022
2 parents 4579cfb + efa3c92 commit 0451c00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 5 additions & 1 deletion src/resources/datarequest/datarequest.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,11 @@ export default class DataRequestController extends Controller {
if (cacheEnabled) {
let publisherDetails = await PublisherModel.findOne({ _id: ObjectId(accessRecord.publisherObj._id) }).lean();

if (accessRecord.applicationStatus === constants.applicationStatuses.SUBMITTED && publisherDetails['dar-integration']['enabled']) {
if (
accessRecord.applicationStatus === constants.applicationStatuses.SUBMITTED &&
publisherDetails['dar-integration'] &&
publisherDetails['dar-integration']['enabled']
) {
const pubSubMessage = {
id: '',
type: '5safes',
Expand Down
18 changes: 9 additions & 9 deletions src/resources/message/message.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
},
});

// 3. Return undefined if no object(s) exists
// 3. Return undefined if no object(s) exists
if (_.isEmpty(tools)) return undefined;

// 4. Get recipients for new message
Expand Down Expand Up @@ -138,15 +138,16 @@ module.exports = {
const { memberEmails } = teamController.getMemberDetails([...memberIds], [...messageRecipients]);
messageRecipients = [...teamNotificationEmails, ...memberEmails];
} else {
const memberIds = [...subscribedMembersByType.map(m => m.memberid.toString())].filter(ele => ele !== topicObj.createdBy.toString());
const memberIds = [...subscribedMembersByType.map(m => m.memberid.toString())].filter(
ele => ele !== topicObj.createdBy.toString()
);
const creatorObjectId = topicObj.createdBy.toString();
// returns array of objects [{email: '[email protected] '}] for members in subscribed emails users is list of full user object
const { memberEmails } = teamController.getMemberDetails([...memberIds], [...messageRecipients]);
const creatorEmail = await UserModel.findById(creatorObjectId);
messageCreatorRecipient = [{ email: creatorEmail.email}];
messageCreatorRecipient = [{ email: creatorEmail.email }];
messageRecipients = [...teamNotificationEmails, ...memberEmails];
}

} else {
// only if not membersByType but has a team email setup
messageRecipients = [...messageRecipients, ...teamNotificationEmails];
Expand Down Expand Up @@ -188,13 +189,14 @@ module.exports = {

// publish the message to GCP PubSub
const cacheEnabled = parseInt(process.env.CACHE_ENABLED) || 0;

if (cacheEnabled && !isServiceAccount) {
let publisherDetails = await PublisherModel.findOne({ _id: ObjectId(tools[0].publisher._id) }).lean();

if (publisherDetails['dar-integration']['enabled']) {
if (publisherDetails['dar-integration'] && publisherDetails['dar-integration']['enabled']) {
const pubSubMessage = {
id: "",
type: "enquiry",
id: '',
type: 'enquiry',
publisherInfo: {
id: publisherDetails._id,
name: publisherDetails.name,
Expand All @@ -204,14 +206,12 @@ module.exports = {
messageId: message.messageID,
createdDate: message.createdDate,
questionBank: req.body.firstMessage,

},
darIntegration: publisherDetails['dar-integration'],
};
await publishMessageWithRetryToPubSub(process.env.PUBSUB_TOPIC_ENQUIRY, JSON.stringify(pubSubMessage));
}
}

}
// 19. Return successful response with message data
const messageObj = message.toObject();
Expand Down
3 changes: 2 additions & 1 deletion src/resources/search/search.repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,11 @@ export async function getObjectResult(type, searchAll, searchQuery, startIndex,
'datasetfields.abstract': 1,
'datasetfields.ageBand': 1,
'datasetfields.phenotypes': 1,
'datasetv2.accessibility.access.deliveryLeadTime': 1,
'datasetv2.summary.publisher.name': 1,
'datasetv2.summary.publisher.logo': 1,
'datasetv2.summary.publisher.memberOf': 1,
'datasetv2.provenance.temporal.accrualPeriodicity': 1,
'datasetv2.provenance.temporal.accrualPeriodicity': 1,

'persons.id': 1,
'persons.firstname': 1,
Expand Down

0 comments on commit 0451c00

Please sign in to comment.