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 2021/03/31 08:59:57 UTC
[incubator-ponymail-foal] 02/02: convert to proper List-ID format
AFTER asserts
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 55c4bb4fbde9688c8f380bbfdc32f7222bc88711
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Mar 31 10:59:32 2021 +0200
convert to proper List-ID format AFTER asserts
---
server/endpoints/mgmt.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/server/endpoints/mgmt.py b/server/endpoints/mgmt.py
index 9002e05..fcc9f02 100644
--- a/server/endpoints/mgmt.py
+++ b/server/endpoints/mgmt.py
@@ -66,7 +66,7 @@ async def process(
elif action == "edit":
new_from = indata.get("from")
new_subject = indata.get("subject")
- new_list = "<" + indata.get("list", "").strip("<>").replace("@", ".") + ">" # foo@bar.baz -> <foo.bar.baz>
+ new_list = indata.get("list")
private = True if indata.get("private", "no") == "yes" else False
new_body = indata.get("body")
@@ -76,6 +76,9 @@ async def process(
assert isinstance(new_list, str), "List ID field must be a text string!"
assert isinstance(new_body, str), "Email body must be a text string!"
+ # Convert List-ID after verification
+ lid = "<" + new_list.strip("<>").replace("@", ".") + ">" # foo@bar.baz -> <foo.bar.baz>
+
email = await plugins.mbox.get_email(session, permalink=doc)
if email and isinstance(email, dict) and plugins.aaa.can_access_email(session, email):
email["from_raw"] = new_from
@@ -83,8 +86,8 @@ async def process(
email["subject"] = new_subject
email["private"] = private
origin_lid = email["list_raw"]
- email["list"] = new_list
- email["list_raw"] = new_list
+ email["list"] = lid
+ email["list_raw"] = lid
email["body"] = new_body
# Save edited email
@@ -111,7 +114,7 @@ async def process(
"author": f"{session.credentials.uid}@{session.credentials.oauth_provider}",
"target": doc,
"lid": origin_lid,
- "log": f"Edited email {doc} from {origin_lid} archives ({origin_lid} -> {new_list})",
+ "log": f"Edited email {doc} from {origin_lid} archives ({origin_lid} -> {lid})",
},
)
return aiohttp.web.Response(headers={}, status=200, text=f"Email successfully saved")