You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/09/07 03:07:55 UTC

[incubator-ponymail-foal] branch humbedooh/47-private-years updated: Restrict search to accessible lists, not just public ones.

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch humbedooh/47-private-years
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/humbedooh/47-private-years by this push:
     new f8ba6c9  Restrict search to accessible lists, not just public ones.
f8ba6c9 is described below

commit f8ba6c902d43f359db63e59a7727216f5104fbc0
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Sep 6 22:07:53 2021 -0500

    Restrict search to accessible lists, not just public ones.
    
    This addresses #47
---
 server/plugins/messages.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 7a7dd62..74d4dbc 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -420,11 +420,17 @@ async def get_years(session, query_defuzzed):
         private_lists_found.append(listname)
 
     # If we can access all private lists found, or if no private lists, we can do a complete search.
-    # If not, we adjust the search here to only include public emails
+    # If not, we adjust the search here to only include public emails OR private lists we can access.
+    private_lists_accessible = []
     for listname in private_lists_found:
-        if not plugins.aaa.can_access_list(session, listname):
-            query_defuzzed["filter"] = [{"term": {"private": False}}]
-            break
+        if plugins.aaa.can_access_list(session, listname):
+            private_lists_accessible.append(listname)
+    
+    # If we can't access all private lists found, either only public emails or lists we can access.
+    if private_lists_found != private_lists_accessible:
+        query_defuzzed["filter"] = [
+            {"bool": {"should": [{"term": {"private": False}}, {"terms": {"list_raw": private_lists_accessible}}]}}
+        ]
 
     # Get oldest doc
     res = await session.database.search(