From 3a51f11f12f8f8d4f6616843300a27eb2d32a137 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 29 Apr 2024 03:15:47 +1200 Subject: [PATCH] support for showing received attachments --- index.html | 17 ++++++++++++++++- web.py | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 4f511fd..711651a 100644 --- a/index.html +++ b/index.html @@ -68,7 +68,7 @@ -
+
You Error @@ -80,6 +80,21 @@
+
+ +
+ + + +
+
{{ file_attachment.file_name }}
+
+ + + +
+
+
diff --git a/web.py b/web.py index a057e6f..0c1aed2 100644 --- a/web.py +++ b/web.py @@ -107,6 +107,25 @@ def lxmf_delivery(message): value = message_fields[field_type] + # handle file attachments field + if field_type == LXMF.FIELD_FILE_ATTACHMENTS: + + # process file attachments + file_attachments = [] + for file_attachment in value: + file_name = file_attachment[0] + file_bytes = base64.b64encode(file_attachment[1]).decode("utf-8") + file_attachments.append({ + "file_name": file_name, + "file_bytes": file_bytes, + }) + + # add to fields + fields.append({ + "type": "file_attachments", + "file_attachments": file_attachments, + }) + # handle image field if field_type == LXMF.FIELD_IMAGE: image_type = value[0]