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 6a65c46  Improve naming of custom downloads
6a65c46 is described below

commit 6a65c46d64bc0bce638c235c792aa5ff5fc1c6a7
Author: Sebb <[email protected]>
AuthorDate: Sun Sep 19 17:31:07 2021 +0100

    Improve naming of custom downloads
---
 server/endpoints/mbox.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py
index 815815f..392f3e8 100644
--- a/server/endpoints/mbox.py
+++ b/server/endpoints/mbox.py
@@ -67,9 +67,14 @@ async def process(
 ) -> typing.Union[dict, aiohttp.web.Response, aiohttp.web.StreamResponse]:
 
     lid = indata.get("list", "_")
+    if lid == '*':
+        lid = 'all'
     domain = indata.get("domain", "_")
+    if domain == '*':
+        domain = 'all'
     # may be provided as d= or date=
     yyyymm = indata.get("d") or indata.get("date") # e.g. 2019-9; can also be 
lte=1M etc
+    q = indata.get("q")
 
     try:
         query_defuzzed = plugins.defuzzer.defuzz(indata, list_override="@" in 
lid and lid or None)
@@ -88,14 +93,15 @@ async def process(
         epoch_order="asc"
     )
 
+    dlstem = f"{lid}_{domain}"
     if yyyymm:
         if len(yyyymm) == 6 and yyyymm[4] == '-': # assume yyyy-m, convert to 
yyyy-mm
             yyyymm = yyyymm[0:-1] + "0" + yyyymm[-1]
-        dlstem = f"{lid}_{domain}_{yyyymm}"
-    else:
-        dlstem = f"{lid}_{domain}"
+        dlstem = f"{dlstem}_{yyyymm}"
+    if q:
+        dlstem = f"{dlstem}_{q}"
     # Figure out a sane filename stem (don't keep '.')
-    dlstem = re.sub(r"[^-_a-z0-9]+", "_", dlstem)
+    dlstem = re.sub(r"[^-_a-zA-Z0-9]+", "_", dlstem)
     headers = {"Content-Type": "application/mbox", "Content-Disposition": 
f"attachment; filename={dlstem}.mbox"}
 
     # Return mbox archive with filename as a stream

Reply via email to