[email] Generate URL directly

This commit is contained in:
maike 2020-07-06 17:00:24 +02:00 committed by dl6tom
parent 71f80a2a96
commit 5e93549591

View file

@ -6,8 +6,8 @@ from fastapi import APIRouter, Depends, HTTPException, status
from kibicara.platforms.email.bot import spawner from kibicara.platforms.email.bot import spawner
from kibicara.platforms.email.model import Email, EmailRecipients from kibicara.platforms.email.model import Email, EmailRecipients
from kibicara.platformapi import Message from kibicara.platformapi import Message
from kibicara.config import config
from kibicara.webapi.hoods import get_hood from kibicara.webapi.hoods import get_hood
from kibicara.webapi.admin import url
from kibicara.email import send_email from kibicara.email import send_email
from ormantic.exceptions import NoMatch from ormantic.exceptions import NoMatch
from pydantic import BaseModel from pydantic import BaseModel
@ -63,7 +63,7 @@ async def email_recipient_create(recipient: Recipient):
'email': recipient.email, 'email': recipient.email,
'hood': recipient.hood, 'hood': recipient.hood,
}, Email.secret).decode('ascii') }, Email.secret).decode('ascii')
confirm_link = url("/api/email/recipient/confirm/" + token) confirm_link = config['root_url'] + "api/email/recipient/confirm/" + token
hood_name = await get_hood(recipient.hood) hood_name = await get_hood(recipient.hood)
send_email(recipient.email, send_email(recipient.email,
"Subscribe to Kibicara " + hood_name, "Subscribe to Kibicara " + hood_name,