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""