aboutsummaryrefslogtreecommitdiff
path: root/mu4web/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'mu4web/main.py')
-rw-r--r--mu4web/main.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/mu4web/main.py b/mu4web/main.py
index 86a0b38..a35d7c4 100644
--- a/mu4web/main.py
+++ b/mu4web/main.py
@@ -87,9 +87,13 @@ def attachement_tree(id: str, mail: EmailMessage, idx=0) -> tuple[HTML, int]:
body = f'{ct} {fn}'
else:
body = str(ct)
+ download = {}
+ if mail.get_content_type() == 'application/octet-stream':
+ download['download'] = mail.get_filename() or ''
return ('li', ('a', {'data-idx': str(_idx),
'href': '/part?' + urlencode({'id': id,
'idx': _idx}),
+ **download,
}, body), content), idx
# --------------------------------------------------
@@ -214,6 +218,11 @@ def response_for(id: str, username: Optional[str] = None) -> str:
}))
elif at.get_content_type() == 'text/plain':
body.append(('pre', at.get_content()))
+ elif at.get_content_type() == 'application/octet-stream':
+ url = '/part?' + urlencode({'id': id, 'idx': idx})
+ body.append(('a', {'href': url,
+ 'download': at.get_filename() or ''},
+ at.get_filename() or at.get_content_type()))
else:
url = '/part?' + urlencode({'id': id, 'idx': idx})
body.append(('a', {'href': url},