Skip to content
Open
Changes from all commits
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
15 changes: 10 additions & 5 deletions module/solutions/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ module.exports = class SolutionsHelper {
},
['type', 'status', 'endDate', 'startDate']
)

//------------------------->
// updated condition, if solution is inactive no need to check further
if (!Array.isArray(solutionData) || solutionData.length < 1) {
return resolve({
Expand All @@ -1440,7 +1440,7 @@ module.exports = class SolutionsHelper {
result: [],
})
}

//------------------------->
if (solutionData[0].endDate && new Date() > new Date(solutionData[0].endDate)) {
if (solutionData[0].status === CONSTANTS.common.ACTIVE_STATUS) {
let updateSolution = await this.update(
Expand Down Expand Up @@ -1471,7 +1471,7 @@ module.exports = class SolutionsHelper {
success: false,
})
}

//------------------------->
// check start date is greater than current date
if (solutionData[0].startDate && new Date() < new Date(solutionData[0].startDate)) {
//isValidStartDate is passed in this situation and based on that key only verifyLink function should return message
Expand All @@ -1487,6 +1487,7 @@ module.exports = class SolutionsHelper {
returnError: true,
})
}
//------------------------->
response.verified = true
return resolve({
success: true,
Expand Down Expand Up @@ -1730,11 +1731,12 @@ module.exports = class SolutionsHelper {

queryData.data['link'] = link
let matchQuery = queryData.data
//------------------------->
// here we have to identify if the solution is targetted or not regardless of time (solution active or not)
if (matchQuery.status) {
delete matchQuery.status
}

//------------------------->
matchQuery['tenantId'] = userDetails.userInformation.tenantId

let solutionData = await solutionsQueries.solutionsDocument(matchQuery, [
Expand Down Expand Up @@ -1769,7 +1771,9 @@ module.exports = class SolutionsHelper {
? solutionDetails[0].projectTemplateId
: ''
response.programName = solutionDetails[0].programName
//------------------------->
response.status = solutionDetails[0].status // this status is required to know whether the solution is active or inactive at verifyLink function.
//------------------------->
delete response._id

return resolve({
Expand Down Expand Up @@ -2848,6 +2852,7 @@ module.exports = class SolutionsHelper {
try {
let verifySolution = await this.verifySolutionDetails(link, userId, userToken, userDetails)

//------------------------->
// if link access is requested before start date return error
if (verifySolution.returnError) {
throw {
Expand All @@ -2857,7 +2862,7 @@ module.exports = class SolutionsHelper {
: messageConstants.apiResponses.INVALID_LINK,
}
}

//------------------------->
let checkForTargetedSolution = await this.checkForTargetedSolution(link, bodyData, userDetails)

if (!checkForTargetedSolution || Object.keys(checkForTargetedSolution.result).length <= 0) {
Expand Down