From 6c83d253123debfc86b0746da70f1d5f6ca2385c Mon Sep 17 00:00:00 2001 From: enginefeeder101 Date: Tue, 26 Apr 2022 21:54:25 +0200 Subject: [PATCH] Configurable default spam threshold used for new users This commit adds functionality to set a custom default spam threshold for new users. The environment variable ``DEFAULT_SPAM_THRESHOLD`` can be used for this purpose. When not set, it defaults back to 80%, as the default value was before If ``DEFAULT_SPAM_THRESHOLD`` is set to a value that Python cannot parse as an integer, a ValueError is thrown. There is no error handling for that case built-in. --- core/admin/mailu/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py index 08738600..6e277fe3 100644 --- a/core/admin/mailu/models.py +++ b/core/admin/mailu/models.py @@ -509,7 +509,8 @@ class User(Base, Email): displayed_name = db.Column(db.String(160), nullable=False, default='') spam_enabled = db.Column(db.Boolean, nullable=False, default=True) spam_mark_as_read = db.Column(db.Boolean, nullable=False, default=True) - spam_threshold = db.Column(db.Integer, nullable=False, default=80) + spam_threshold = db.Column(db.Integer, nullable=False, + default=int(os.environ.get('DEFAULT_SPAM_THRESHOLD', 80))) # Flask-login attributes is_authenticated = True