aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-12-01 14:42:27 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-12-01 14:42:27 +0100
commitf892ccd41a60fbb847e12fad59fca7bd61dfc72e (patch)
treeca7b52700ccd8509478b2e8b488298fc2d597404
parentResolve TODO about source of randomness. (diff)
downloadmu4web-f892ccd41a60fbb847e12fad59fca7bd61dfc72e.tar.gz
mu4web-f892ccd41a60fbb847e12fad59fca7bd61dfc72e.tar.xz
Made mail header set configurable.
-rw-r--r--instance/settings.py17
-rw-r--r--mu4web/main.py15
2 files changed, 27 insertions, 5 deletions
diff --git a/instance/settings.py b/instance/settings.py
index 627b6a6..654e351 100644
--- a/instance/settings.py
+++ b/instance/settings.py
@@ -9,3 +9,20 @@ DEFAULT_DIRECTION = 'falling'
# >>> os.urandom(24)
SECRET_KEY = b"\x13\xbd\xaa'\x9d\xe9P\x83\xf1h\xd0\xc7\x893@\x80\xd3fP\x83\x8bMt\x8d"
+# Headers to show on the single message view.
+# Only includes those of these that exists
+# This also controls the order they appear
+MESSAGE_HEADERS = [
+ 'from',
+ 'subject',
+ 'to',
+ 'cc',
+ 'date',
+ 'x-url',
+ 'user-agent',
+ 'x-spam-score',
+ 'x-original-to',
+ 'in-reply-to',
+ 'delivered-to',
+ 'message-id',
+]
diff --git a/mu4web/main.py b/mu4web/main.py
index ef7624a..f901aec 100644
--- a/mu4web/main.py
+++ b/mu4web/main.py
@@ -181,9 +181,7 @@ def response_for(id: str) -> str:
headers[key.lower()] = value
head = []
- # TODO Make the defalut set of headers configurable
- for h in ['date', 'from', 'to', 'cc', 'bcc', 'subject', 'x-original-to',
- 'in-reply-to', 'message-id']:
+ for h in app.config['MESSAGE_HEADERS']:
if x := headers.get(h.lower()):
head += [('dt', h.title()),
('dd', header_format(h.lower(), x))]
@@ -339,8 +337,15 @@ app = Flask(__name__, instance_relative_config=True)
# Default configuration values
app.config.update(
- DEFAULT_DIRECTION = 'falling',
- DEFAULT_SORT_COLUMN = 'date',
+ DEFAULT_DIRECTION='falling',
+ DEFAULT_SORT_COLUMN='date',
+ MESSAGE_HEADERS=[
+ 'from',
+ 'subject',
+ 'to',
+ 'cc',
+ 'date',
+ ]
)
app.config.from_pyfile('settings.py')