[email] Coding style fix
This commit is contained in:
parent
0068558efb
commit
43b8ec8373
|
@ -8,6 +8,7 @@ from ormantic import Integer, ForeignKey, Model, Text
|
||||||
|
|
||||||
class EmailSubscribers(Model):
|
class EmailSubscribers(Model):
|
||||||
""" This table stores all subscribers, who want to receive messages via email. """
|
""" This table stores all subscribers, who want to receive messages via email. """
|
||||||
|
|
||||||
id: Integer(primary_key=True) = None
|
id: Integer(primary_key=True) = None
|
||||||
hood: ForeignKey(Hood)
|
hood: ForeignKey(Hood)
|
||||||
email: Text()
|
email: Text()
|
||||||
|
@ -18,6 +19,7 @@ class EmailSubscribers(Model):
|
||||||
|
|
||||||
class Email(Model):
|
class Email(Model):
|
||||||
""" This table is used to track the hood ID. It also stores the token secret. """
|
""" This table is used to track the hood ID. It also stores the token secret. """
|
||||||
|
|
||||||
id: Integer(primary_key=True) = None
|
id: Integer(primary_key=True) = None
|
||||||
hood: ForeignKey(Hood)
|
hood: ForeignKey(Hood)
|
||||||
secret: Text()
|
secret: Text()
|
||||||
|
|
|
@ -20,6 +20,7 @@ from os import urandom
|
||||||
|
|
||||||
class BodyMessage(BaseModel):
|
class BodyMessage(BaseModel):
|
||||||
""" This model shows which values are supplied by the MDA listener script. """
|
""" This model shows which values are supplied by the MDA listener script. """
|
||||||
|
|
||||||
text: str
|
text: str
|
||||||
to: str
|
to: str
|
||||||
author: str
|
author: str
|
||||||
|
@ -28,6 +29,7 @@ class BodyMessage(BaseModel):
|
||||||
|
|
||||||
class Subscriber(BaseModel):
|
class Subscriber(BaseModel):
|
||||||
""" This model holds the email address of a fresh subscriber. """
|
""" This model holds the email address of a fresh subscriber. """
|
||||||
|
|
||||||
email: str
|
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.
|
:return: Returns status code 200 after sending confirmation email.
|
||||||
"""
|
"""
|
||||||
secretbox = SecretBox(Email.secret)
|
secretbox = SecretBox(Email.secret)
|
||||||
token = secretbox.encrypt({'email': subscriber.email, }, encoder=URLSafeBase64Encoder)
|
token = secretbox.encrypt(
|
||||||
|
{'email': subscriber.email,}, encoder=URLSafeBase64Encoder
|
||||||
|
)
|
||||||
asciitoken = token.decode('ascii')
|
asciitoken = token.decode('ascii')
|
||||||
confirm_link = (
|
confirm_link = (
|
||||||
config['root_url'] + "api/" + hood.id + "/email/subscribe/confirm/" + asciitoken
|
config['root_url'] + "api/" + hood.id + "/email/subscribe/confirm/" + asciitoken
|
||||||
|
|
Loading…
Reference in a new issue