[email] Envelope from is not always set

This commit is contained in:
maike 2020-07-13 04:19:04 +02:00 committed by dl6tom
parent b54b6d0e24
commit 075d04bb7d

View file

@ -56,15 +56,17 @@ async def async_main(mail=None, hood_name=None):
print('No hood with this name') print('No hood with this name')
exit(1) exit(1)
email_row = await Email.objects.get(hood=hood) email_row = await Email.objects.get(hood=hood)
author = mail.get_unixfrom()
if author is None:
author = mail['From']
body = { body = {
'text': text, 'text': text,
'author': mail.get_unixfrom(), 'author': author,
'secret': email_row.secret, 'secret': email_row.secret,
} }
response = requests.post( response = requests.post(
'http://localhost:8000/api/hoods/%d/email/messages/' % hood.id, json=body 'http://localhost:8000/api/hoods/%d/email/messages/' % hood.id, json=body
) )
print("Request sent:")
if response.status_code == status.HTTP_201_CREATED: if response.status_code == status.HTTP_201_CREATED:
exit(0) exit(0)
elif response.status_code == status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS: elif response.status_code == status.HTTP_451_UNAVAILABLE_FOR_LEGAL_REASONS: