From 0830bba2186f049196e7f55807417576d2a731f5 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Mon, 28 Sep 2020 17:40:54 +0200 Subject: [PATCH] Add AuthorizedAddress model --- app/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/models.py b/app/models.py index c7b6a0c3..56ed883f 100644 --- a/app/models.py +++ b/app/models.py @@ -1812,3 +1812,22 @@ class BatchImport(db.Model, ModelMixin): def __repr__(self): return f"" + + +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""