You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/12/13 15:25:16 UTC

[incubator-ponymail-foal] branch master updated: Allow for mixed public/private lists

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

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a4c717  Allow for mixed public/private lists
1a4c717 is described below

commit 1a4c717334ffadcad22367514c379ca6c5065a61
Author: Sebb <se...@apache.org>
AuthorDate: Mon Dec 13 15:24:40 2021 +0000

    Allow for mixed public/private lists
    
    This fixes #175
---
 server/plugins/background.py | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/server/plugins/background.py b/server/plugins/background.py
index 8ebd351..1fefdff 100644
--- a/server/plugins/background.py
+++ b/server/plugins/background.py
@@ -61,9 +61,10 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict:
     db = plugins.database.Database(database)
     limit = database.max_lists
 
-    # Fetch aggregations of all public emails
+    # Fetch aggregations of all private emails
+    # Do this first, so mixed lists are not marked private
     s = Search(using=db.client, index=db.dbs.mbox).filter(
-        "term", private=False
+        "term", private=True
     )
     s.aggs.bucket("per_list", "terms", field="list_raw", size=limit)
 
@@ -74,13 +75,13 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict:
     for ml in res["aggregations"]["per_list"]["buckets"]:
         list_name = ml["key"].strip("<>").replace(".", "@", 1)
         lists[list_name] = {
-            "count": 0,   # We'll sort this later
-            "private": False,
+            "count": 0,  # Sorting later
+            "private": True,
         }
 
-    # Ditto, for private emails
+    # Fetch aggregations of all public emails
     s = Search(using=db.client, index=db.dbs.mbox).filter(
-        "term", private=True
+        "term", private=False
     )
     s.aggs.bucket("per_list", "terms", field="list_raw", size=limit)
 
@@ -91,8 +92,8 @@ async def get_lists(database: plugins.configuration.DBConfig) -> dict:
     for ml in res["aggregations"]["per_list"]["buckets"]:
         list_name = ml["key"].strip("<>").replace(".", "@", 1)
         lists[list_name] = {
-            "count": 0,  # Sorting later
-            "private": True,
+            "count": 0,   # We'll sort this later
+            "private": False,
         }
 
     # Get 90 day activity, if any