[email] Fix database call for API secret

This commit is contained in:
maike 2020-07-09 11:39:51 +02:00 committed by dl6tom
parent c2bdbc6f88
commit ae9e931c43

View file

@ -9,10 +9,11 @@ import requests
from logging import getLogger from logging import getLogger
from kibicara.platforms.email.model import Email from kibicara.platforms.email.model import Email
from kibicara.model import Hood from kibicara.model import Hood
from kibicara.platforms.email.webapi import get_email
import argparse import argparse
def main(): async def main():
logger = getLogger(__name__) logger = getLogger(__name__)
# the MDA passes the recipient address as command line argument # the MDA passes the recipient address as command line argument
@ -41,9 +42,10 @@ def main():
# extract hood name from the envelope recipient address # extract hood name from the envelope recipient address
hood_name = args.recipient_address.split('@')[0] hood_name = args.recipient_address.split('@')[0]
hood = await Hood.objects.get(name=hood_name) hood = await Hood.objects.get(name=hood_name)
email_row = await get_email(hood=hood.id)
body = { body = {
'text': text, 'text': text,
'author': mail.get_unixfrom(), 'author': mail.get_unixfrom(),
'secret': Email.secret, 'secret': email_row.secret,
} }
requests.post('http://localhost/api/' + hood.id + '/email/messages/', data=body) requests.post('http://localhost/api/%d/email/messages/' % hood.id, data=body)