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 2020/09/08 10:20:03 UTC
[incubator-ponymail-foal] branch master updated (ef1f950 -> 8637d5c)
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.
from ef1f950 name and email might not always be passed to us
new 69a19a4 Add endpoint for downloading mbox archives
new 7f5bf96 Pass search params back to client
new 8637d5c Use search params to construct mbox URL
The 3 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/endpoints/mbox.py | 71 ++++++++++++++++++++++++++++++++++++++
server/endpoints/stats.py | 1 +
webui/js/ponymail.js | 7 ++++
webui/js/source/listview-header.js | 7 ++++
4 files changed, 86 insertions(+)
create mode 100644 server/endpoints/mbox.py
[incubator-ponymail-foal] 02/03: Pass search params back to client
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 7f5bf9662083b8cc32272ff63b7f0306484f41b7
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 12:19:27 2020 +0200
Pass search params back to client
---
server/endpoints/stats.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/endpoints/stats.py b/server/endpoints/stats.py
index 2f470f6..c9f6568 100644
--- a/server/endpoints/stats.py
+++ b/server/endpoints/stats.py
@@ -83,6 +83,7 @@ async def process(
"search_list": f"<{xlist}.{xdomain}>",
"domain": xdomain,
"list": f"{xlist}@{xdomain}",
+ "searchParams": indata,
}
[incubator-ponymail-foal] 01/03: Add endpoint for downloading mbox
archives
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 69a19a49dc329e8e53f0fd36d374ea9375a56b9a
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 12:19:05 2020 +0200
Add endpoint for downloading mbox archives
---
server/endpoints/mbox.py | 71 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/server/endpoints/mbox.py b/server/endpoints/mbox.py
new file mode 100644
index 0000000..14b811e
--- /dev/null
+++ b/server/endpoints/mbox.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Endpoint for returning emails in mbox format as a single archive"""
+import plugins.server
+import plugins.session
+import plugins.mbox
+import plugins.defuzzer
+import re
+import typing
+import aiohttp.web
+
+
+async def process(
+ server: plugins.server.BaseServer,
+ session: plugins.session.SessionObject,
+ indata: dict,
+) -> typing.Union[dict, aiohttp.web.Response]:
+
+ query_defuzzed = plugins.defuzzer.defuzz(indata)
+ results = await plugins.mbox.query(
+ session, query_defuzzed, query_limit=server.config.database.max_hits,
+ )
+
+ sources = []
+ for email in results:
+ source = await plugins.mbox.get_source(session, permalink=email["mid"])
+ if source:
+ stext = source["_source"]["source"]
+ # Convert to mboxrd format
+ mboxrd_source = ""
+ line_no = 0
+ for line in stext.split("\n"):
+ line_no += 1
+ if line_no > 1 and re.match(r"^>*From\s+", line):
+ line = ">" + line
+ mboxrd_source += line + "\n"
+ sources.append(mboxrd_source)
+
+ # Figure out a sane filename
+ xlist = re.sub(r"[^-_.a-z0-9]+", "_", indata.get("list", "_"))
+ xdomain = re.sub(r"[^-_.a-z0-9]+", "_", indata.get("domain", "_"))
+ dlfile = f"{xlist}-{xdomain}.mbox"
+
+ # Return mbox archive with filename
+ return aiohttp.web.Response(
+ headers={
+ "Content-Type": "application/mbox",
+ "Content-Disposition": f"attachment; filename={dlfile}",
+ },
+ status=200,
+ text="\n\n".join(sources),
+ )
+
+
+def register(server: plugins.server.BaseServer):
+ return plugins.server.Endpoint(process)
[incubator-ponymail-foal] 03/03: Use search params to construct
mbox URL
Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 8637d5c856aa3f291031cff658bb904d0764b825
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 12:19:51 2020 +0200
Use search params to construct mbox URL
---
webui/js/ponymail.js | 7 +++++++
webui/js/source/listview-header.js | 7 +++++++
2 files changed, 14 insertions(+)
diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index c034727..37b407e 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -2016,6 +2016,13 @@ function listview_header(state, json) {
document.getElementById('listview_title').innerText = list_title + ":";
let download = new HTML('button', { title: 'Download as mbox archive', download: 'true'}, new HTML('span', {class: 'glyphicon glyphicon-save'}, " "));
document.getElementById('listview_title').inject(download);
+ download.addEventListener('click', () => {
+ dl_url = pm_config.apiURL + 'api/mbox.lua?';
+ for (let key in json.searchParams || {}) {
+ dl_url += key + "=" + encodeURIComponent(json.searchParams[key]) + "&";
+ }
+ location.href = dl_url;
+ });
let chevrons = document.getElementById('listview_chevrons');
let per_page = calc_per_page();
diff --git a/webui/js/source/listview-header.js b/webui/js/source/listview-header.js
index 80fe9fb..91ebf40 100644
--- a/webui/js/source/listview-header.js
+++ b/webui/js/source/listview-header.js
@@ -38,6 +38,13 @@ function listview_header(state, json) {
document.getElementById('listview_title').innerText = list_title + ":";
let download = new HTML('button', { title: 'Download as mbox archive', download: 'true'}, new HTML('span', {class: 'glyphicon glyphicon-save'}, " "));
document.getElementById('listview_title').inject(download);
+ download.addEventListener('click', () => {
+ dl_url = pm_config.apiURL + 'api/mbox.lua?';
+ for (let key in json.searchParams || {}) {
+ dl_url += key + "=" + encodeURIComponent(json.searchParams[key]) + "&";
+ }
+ location.href = dl_url;
+ });
let chevrons = document.getElementById('listview_chevrons');
let per_page = calc_per_page();