Add AuthorizedAddress model

This commit is contained in:
Son NK 2020-09-28 17:40:54 +02:00
parent d6d686c4c3
commit 0830bba218

View file

@ -1812,3 +1812,22 @@ class BatchImport(db.Model, ModelMixin):
def __repr__(self): def __repr__(self):
return f"<BatchImport {self.id}>" return f"<BatchImport {self.id}>"
class AuthorizedAddress(db.Model, ModelMixin):
"""Authorize other addresses to send emails from aliases that are owned by a mailbox"""
user_id = db.Column(db.ForeignKey(User.id, ondelete="cascade"), nullable=False)
mailbox_id = db.Column(
db.ForeignKey(Mailbox.id, ondelete="cascade"), nullable=False
)
email = db.Column(db.String(256), nullable=False)
__table_args__ = (
db.UniqueConstraint("mailbox_id", "email", name="uq_authorize_address"),
)
mailbox = db.relationship(Mailbox, backref="authorized_addresses")
def __repr__(self):
return f"<AuthorizedAddress {self.id} {self.email} {self.mailbox_id}>"