From 075d04bb7dd7160e2d719ab3e21039f0a71015e6 Mon Sep 17 00:00:00 2001 From: maike Date: Mon, 13 Jul 2020 04:19:04 +0200 Subject: [PATCH] [email] Envelope from is not always set --- kibicara/kibicara_mda.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kibicara/kibicara_mda.py b/kibicara/kibicara_mda.py index ad7a29f..002a947 100644 --- a/kibicara/kibicara_mda.py +++ b/kibicara/kibicara_mda.py @@ -56,15 +56,17 @@ async def async_main(mail=None, hood_name=None): print('No hood with this name') exit(1) email_row = await Email.objects.get(hood=hood) + author = mail.get_unixfrom() + if author is None: + author = mail['From'] body = { 'text': text, - 'author': mail.get_unixfrom(), + 'author': author, 'secret': email_row.secret, } response = requests.post( 'http://localhost:8000/api/hoods/%d/email/messages/' % hood.id, json=body ) - print("Request sent:") if response.status_code == status.HTTP_201_CREATED: exit(0) elif response.status_code == status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS: