diff --git a/kibicara/platforms/email/model.py b/kibicara/platforms/email/model.py index dd71145..9b479ad 100644 --- a/kibicara/platforms/email/model.py +++ b/kibicara/platforms/email/model.py @@ -8,6 +8,7 @@ from ormantic import Integer, ForeignKey, Model, Text class EmailSubscribers(Model): """ This table stores all subscribers, who want to receive messages via email. """ + id: Integer(primary_key=True) = None hood: ForeignKey(Hood) email: Text() @@ -18,6 +19,7 @@ class EmailSubscribers(Model): class Email(Model): """ This table is used to track the hood ID. It also stores the token secret. """ + id: Integer(primary_key=True) = None hood: ForeignKey(Hood) secret: Text() diff --git a/kibicara/platforms/email/webapi.py b/kibicara/platforms/email/webapi.py index d9e23d7..7dd5f80 100644 --- a/kibicara/platforms/email/webapi.py +++ b/kibicara/platforms/email/webapi.py @@ -20,6 +20,7 @@ from os import urandom class BodyMessage(BaseModel): """ This model shows which values are supplied by the MDA listener script. """ + text: str to: str author: str @@ -28,6 +29,7 @@ class BodyMessage(BaseModel): class Subscriber(BaseModel): """ This model holds the email address of a fresh subscriber. """ + email: str @@ -86,7 +88,9 @@ async def email_subscribe(subscriber: Subscriber, hood=Depends(get_hood)): :return: Returns status code 200 after sending confirmation email. """ secretbox = SecretBox(Email.secret) - token = secretbox.encrypt({'email': subscriber.email, }, encoder=URLSafeBase64Encoder) + token = secretbox.encrypt( + {'email': subscriber.email,}, encoder=URLSafeBase64Encoder + ) asciitoken = token.decode('ascii') confirm_link = ( config['root_url'] + "api/" + hood.id + "/email/subscribe/confirm/" + asciitoken