|
|
|
@ -30,11 +30,11 @@ DEFAULT_CONFIG = {
|
|
|
|
|
'POSTMASTER': 'postmaster',
|
|
|
|
|
'TLS_FLAVOR': 'cert',
|
|
|
|
|
'AUTH_RATELIMIT': '10/minute;1000/hour',
|
|
|
|
|
'DISABLE_STATISTICS': 'False',
|
|
|
|
|
'DISABLE_STATISTICS': False,
|
|
|
|
|
# Mail settings
|
|
|
|
|
'DMARC_RUA': None,
|
|
|
|
|
'DMARC_RUF': None,
|
|
|
|
|
'WELCOME': 'False',
|
|
|
|
|
'WELCOME': False,
|
|
|
|
|
'WELCOME_SUBJECT': 'Dummy welcome topic',
|
|
|
|
|
'WELCOME_BODY': 'Dummy welcome body',
|
|
|
|
|
'DKIM_SELECTOR': 'dkim',
|
|
|
|
@ -74,13 +74,21 @@ class ConfigManager(dict):
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.config = dict()
|
|
|
|
|
|
|
|
|
|
def __coerce_value(self, value):
|
|
|
|
|
if isinstance(value, str) and value.lower() in ('true','yes'):
|
|
|
|
|
return True
|
|
|
|
|
elif isinstance(value, str) and value.lower() in ('false', 'no'):
|
|
|
|
|
return False
|
|
|
|
|
return value
|
|
|
|
|
|
|
|
|
|
def init_app(self, app):
|
|
|
|
|
self.config.update(app.config)
|
|
|
|
|
# get environment variables
|
|
|
|
|
self.config.update({
|
|
|
|
|
key: os.environ.get(key, value)
|
|
|
|
|
key: self.__coerce_value(os.environ.get(key, value))
|
|
|
|
|
for key, value in DEFAULT_CONFIG.items()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
# automatically set the sqlalchemy string
|
|
|
|
|
if self.config['DB_FLAVOR']:
|
|
|
|
|
template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]
|
|
|
|
|