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 07:46:12 UTC
[incubator-ponymail-foal] branch master updated (562d88a -> b566735)
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 562d88a start type testing server in travis
new f957930 Session objects should carry a reference to the base server
new dffe4c5 Fix up type errors found by mypy
new be44b43 type test all plugins
new b566735 drop a note about runners
The 4 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:
.travis.yml | 1 +
server/plugins/mbox.py | 15 +++++++++------
server/plugins/oauthGeneric.py | 1 +
server/plugins/oauthGoogle.py | 1 +
server/plugins/session.py | 2 ++
5 files changed, 14 insertions(+), 6 deletions(-)
[incubator-ponymail-foal] 03/04: type test all plugins
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 be44b43c6c3bc6975b85c3792f69f50ab08463f8
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:45:43 2020 +0200
type test all plugins
---
.travis.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.travis.yml b/.travis.yml
index 7001115..c92960a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,6 +26,7 @@ script:
- mypy --ignore-missing-imports tools/archiver.py
- mypy --ignore-missing-imports tools/import-mbox.py
- mypy --ignore-missing-imports server/main.py
+ - mypy --ignore-missing-imports server/plugins/*.py
jobs:
include:
[incubator-ponymail-foal] 04/04: drop a note about runners
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 b566735816c91e27375a5a099ec77e946b843ca6
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:45:59 2020 +0200
drop a note about runners
---
server/plugins/oauthGeneric.py | 1 +
server/plugins/oauthGoogle.py | 1 +
2 files changed, 2 insertions(+)
diff --git a/server/plugins/oauthGeneric.py b/server/plugins/oauthGeneric.py
index fd3ff9d..0676261 100644
--- a/server/plugins/oauthGeneric.py
+++ b/server/plugins/oauthGeneric.py
@@ -9,6 +9,7 @@ async def process(formdata, session, server):
if m:
oauth_domain = m.group(1)
headers = {"User-Agent": "Pony Mail OAuth Agent/0.1"}
+ # This is a synchronous process, so we offload it to an async runner in order to let the main loop continue.
rv = await server.runners.run(requests.post, formdata["oauth_token"], headers=headers, data=formdata)
js = rv.json()
js["oauth_domain"] = oauth_domain
diff --git a/server/plugins/oauthGoogle.py b/server/plugins/oauthGoogle.py
index 153937d..43bed18 100644
--- a/server/plugins/oauthGoogle.py
+++ b/server/plugins/oauthGoogle.py
@@ -15,6 +15,7 @@ import plugins.session
async def process(formdata, session, server: plugins.server.BaseServer):
js = None
request = google.auth.transport.requests.Request()
+ # This is a synchronous process, so we offload it to an async runner in order to let the main loop continue.
id_info = await server.runners.run(
google.oauth2.id_token.verify_oauth2_token,
formdata.get("id_token"),
[incubator-ponymail-foal] 01/04: Session objects should carry a
reference to the base server
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 f95793021a783f5f8d2944140dde80e53784f941
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:44:32 2020 +0200
Session objects should carry a reference to the base server
---
server/plugins/session.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/server/plugins/session.py b/server/plugins/session.py
index f8424fd..087f1c7 100644
--- a/server/plugins/session.py
+++ b/server/plugins/session.py
@@ -68,9 +68,11 @@ class SessionObject:
last_accessed: int
credentials: typing.Optional[SessionCredentials]
database: typing.Optional[plugins.database.Database]
+ server: plugins.server.BaseServer
def __init__(self, server: plugins.server.BaseServer, **kwargs):
self.database = None
+ self.server = server
if not kwargs:
now = int(time.time())
self.created = now
[incubator-ponymail-foal] 02/04: Fix up type errors found by mypy
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 dffe4c5ac19e07f600abc2e74fa69983782242e0
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:45:13 2020 +0200
Fix up type errors found by mypy
---
server/plugins/mbox.py | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/server/plugins/mbox.py b/server/plugins/mbox.py
index a3ac061..787c99a 100644
--- a/server/plugins/mbox.py
+++ b/server/plugins/mbox.py
@@ -39,7 +39,7 @@ import plugins.database
PYPONY_RE_PREFIX = re.compile(r"^([a-zA-Z]+:\s*)+")
-mbox_cache_privacy = {}
+mbox_cache_privacy: typing.Dict[str, bool] = {}
def extract_name(addr):
@@ -83,7 +83,7 @@ async def find_parent(session, doc: typing.Dict[str, str]):
# max 50 steps up in the hierarchy
while step < 50:
step = step + 1
- irt: str = doc["in-reply-to"] if "in-reply-to" in doc else None
+ irt: typing.Optional[str] = doc["in-reply-to"] if "in-reply-to" in doc else None
if not irt:
break # Shouldn't happen because irt is always present currently
# Extract the reference, if any
@@ -152,6 +152,7 @@ async def get_email(
irt=None,
source=False,
):
+ assert session.database, "Database not connected!"
doctype = session.database.dbs.mbox
if source:
doctype = session.database.dbs.source
@@ -199,6 +200,7 @@ async def get_email(
async def get_source(session: plugins.session.SessionObject, permalink: str = None):
+ assert session.database, "Database not connected!"
doctype = session.database.dbs.source
try:
doc = await session.database.get(index=doctype, id=permalink)
@@ -258,6 +260,7 @@ async def query(
"""
docs = []
hits = 0
+ assert session.database, "Database not connected!"
async for hit in async_scan(
client=session.database.client,
query={
@@ -417,16 +420,16 @@ def find_root_subject(threads, hashdict, root_email, osubject=None):
def construct_threads(emails: typing.List[typing.Dict]):
"""Turns a list of emails into a nested thread structure"""
- threads = []
+ threads: typing.List[dict] = []
authors = {}
- hashdict = {}
+ hashdict: typing.Dict[str, dict] = {}
for cur_email in sorted(emails, key=lambda x: x["epoch"]):
author = cur_email.get("from")
if author not in authors:
authors[author] = 0
authors[author] += 1
- subject = cur_email.get("subject").replace("\n", "") # Crop multi-line subjects
- tsubject = PYPONY_RE_PREFIX.sub("", subject) + "_" + cur_email.get("list_raw")
+ subject = cur_email.get("subject", "").replace("\n", "") # Crop multi-line subjects
+ tsubject = PYPONY_RE_PREFIX.sub("", subject) + "_" + cur_email.get("list_raw", "<a.b.c.d>")
parent = find_root_subject(threads, hashdict, cur_email, tsubject)
xemail = {
"children": [],