Skip to content

Commit

Permalink
feat(logs): handles conflicting filters whoID/isariLab/isariRole (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
naholyr committed Sep 25, 2017
1 parent 4340ebc commit 8302d76
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions server/routes/editLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function getEditLog(req, res){

const whoIdsItemIdsP = validParamsP
.then(() => {
if (!query.whoID && (query.isariLab || query.isariRole)){
if (query.isariLab || query.isariRole) {
//need to retrieve list of targeted creators first
const mongoQueryPeople = {}
if (query.isariLab)
Expand Down Expand Up @@ -168,11 +168,15 @@ function getEditLog(req, res){
if (whoIdsItemIds.itemIds)
mongoQuery.item = whoIdsItemIds.itemIds

if (query.whoID)
if (whoIdsItemIds.whoIds) {
if (query.whoID && !whoIdsItemIds.some(id => String(id) === query.whoID)) {
// Conflicting filters: return empty result
return {count: 0, logs: []}
}
mongoQuery['whoID'] = {$in: whoIdsItemIds.whoIds}
} else if (query.whoID) {
mongoQuery['whoID'] = ObjectId(query.whoID)
else
if (whoIdsItemIds.whoIds)
mongoQuery['whoID'] = {$in: whoIdsItemIds.whoIds}
}

if (query.path || query.accessMonitoring) {
const paths1 = query.accessMonitoring ? getAccessMonitoringPaths(model, query.accessMonitoring) : []
Expand Down

0 comments on commit 8302d76

Please sign in to comment.