1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-11-29 22:37:58 +02:00

Created function for returning email type

This commit is contained in:
Ionut Filip
2018-11-21 13:43:06 +01:00
parent 47a3fd47b5
commit 436055f02c

View File

@@ -21,6 +21,11 @@ import dns
db = flask_sqlalchemy.SQLAlchemy()
config = configuration.ConfigManager()
def email_type():
if config['DB_FLAVOR'] == 'postgresql':
return CIText()
else:
return db.String(255, collation="NOCASE")
class IdnaDomain(db.TypeDecorator):
""" Stores a Unicode string in it's IDNA representation (ASCII only)
@@ -58,9 +63,6 @@ class IdnaEmail(db.TypeDecorator):
idna.decode(domain_name),
)
def __init__(self):
if config['DB_FLAVOR'] == 'postgresql':
self.impl = CIText()
class CommaSeparatedList(db.TypeDecorator):
@@ -443,7 +445,7 @@ class Fetch(Base):
__tablename__ = "fetch"
id = db.Column(db.Integer(), primary_key=True)
user_email = db.Column(db.String(255), db.ForeignKey(User.email),
user_email = db.Column(email_type(), db.ForeignKey(User.email),
nullable=False)
user = db.relationship(User,
backref=db.backref('fetches', cascade='all, delete-orphan'))