From 4bf20da433f69c398e26f31b35ca038696c31ec9 Mon Sep 17 00:00:00 2001 From: Tomas Kikutis Date: Thu, 17 Feb 2022 14:52:04 +0100 Subject: [PATCH] Filter out items in personal space except for current user (#4063) --- scripts/apps/search/services/SearchService.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/apps/search/services/SearchService.ts b/scripts/apps/search/services/SearchService.ts index e80913043c..6a4899f4b6 100644 --- a/scripts/apps/search/services/SearchService.ts +++ b/scripts/apps/search/services/SearchService.ts @@ -667,10 +667,18 @@ export function SearchService($location, session, multi, this.filter({not: {term: {state: 'scheduled'}}}); } - // remove other users drafts. - this.filter({or: [{and: [{term: {state: 'draft'}}, - {term: {original_creator: session.identity._id}}]}, - {not: {terms: {state: ['draft']}}}]}); + /** + * Filter out personal items that don't belong to current user. + */ + this.filter({ + not: { + and: [ // matches personal items that belong to other users + {not: {exists: {field: 'task.desk'}}}, + {exists: {field: 'task.user'}}, + {not: {term: {'task.user': session.identity._id}}}, + ], + }, + }); // this is needed for archived collection this.filter({not: {term: {package_type: 'takes'}}});