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/14 20:08:19 UTC

[incubator-ponymail-foal] branch master updated (3dcae8c -> 1355577)

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

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


    from 3dcae8c  Update version
     new 694171e  Only fetch accessible emails
     new 1355577  Update version

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 server/plugins/messages.py | 27 +++++++++++++++++++++------
 server/server_version.py   |  2 +-
 2 files changed, 22 insertions(+), 7 deletions(-)

[incubator-ponymail-foal] 01/02: Only fetch accessible emails

Posted by se...@apache.org.
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

commit 694171e50f5bbb3610c40948314f6d6ac26508cd
Author: Sebb <se...@apache.org>
AuthorDate: Tue Dec 14 20:05:18 2021 +0000

    Only fetch accessible emails
    
    Re-use the get_activity_span code that filters lists
    using a pre-check
    
    This fixes #177
---
 server/plugins/messages.py | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 25e70b7..5c049c0 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -350,6 +350,7 @@ async def query_batch(
     """
     assert session.database, DATABASE_NOT_CONNECTED
     preserve_order = True if epoch_order == "asc" else False
+    query_defuzzed = await filter_accessible(session, query_defuzzed)
     es_query = {
         "query": {"bool": query_defuzzed},
         "sort": [{"epoch": {"order": epoch_order}}],
@@ -462,11 +463,18 @@ async def wordcloud(session: plugins.session.SessionObject, query_defuzzed: dict
         pass
     return wc
 
+async def filter_accessible(session: plugins.session.SessionObject, query_defuzzed: dict) -> dict:
+    """
+    Update query to take account of private emails
+    Reduces the need to filter out emails later
+    """
+    query_copy = dict(query_defuzzed)
+    if not session.credentials:
+        # if no credentials, only need to search public mails
+        query_copy["filter"] = [{"term": {"private": False}}]
+        return query_copy
 
-async def get_activity_span(session: plugins.session.SessionObject, query_defuzzed: dict) -> typing.Tuple[datetime.datetime, datetime.datetime, dict]:
-    """ Fetches the activity span of a search as well as active months within that span """
-
-    # Fetch any private lists included in search results
+    # which private lists might be involved in the search?
     fuzz_private_only = dict(query_defuzzed)
     fuzz_private_only["filter"] = [{"term": {"private": True}}]
     assert session.database, DATABASE_NOT_CONNECTED
@@ -493,12 +501,19 @@ async def get_activity_span(session: plugins.session.SessionObject, query_defuzz
     
     # If we can't access all private lists found, either only public emails or lists we can access.
     if not private_lists_accessible:  # No private lists accessible, just filter for public
-        query_defuzzed["filter"] = [{"term": {"private": False}}]
+        query_copy["filter"] = [{"term": {"private": False}}]
     elif private_lists_found != private_lists_accessible:  # Some private lists, search for public OR those..
-        query_defuzzed["filter"] = [
+        query_copy["filter"] = [
             {"bool": {"should": [{"term": {"private": False}}, {"terms": {"list_raw": private_lists_accessible}}]}}
         ]
 
+    return query_copy
+
+async def get_activity_span(session: plugins.session.SessionObject, query_defuzzed: dict) -> typing.Tuple[datetime.datetime, datetime.datetime, dict]:
+    """ Fetches the activity span of a search as well as active months within that span """
+
+    query_defuzzed = await filter_accessible(session, query_defuzzed)
+
     # Get oldest and youngest doc in single scan, as well as a monthly histogram
     res = await session.database.search(
         index=session.database.dbs.db_mbox,

[incubator-ponymail-foal] 02/02: Update version

Posted by se...@apache.org.
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

commit 1355577f6dfaa702024de6147a7000368fd8b549
Author: Sebb <se...@apache.org>
AuthorDate: Tue Dec 14 20:05:38 2021 +0000

    Update version
---
 server/server_version.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/server_version.py b/server/server_version.py
index 1c9a0d3..66c538c 100644
--- a/server/server_version.py
+++ b/server/server_version.py
@@ -1,2 +1,2 @@
 # This file is generated by server/update_version.sh
-PONYMAIL_SERVER_VERSION = '6aa319f'
+PONYMAIL_SERVER_VERSION = '694171e'