aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-12-01 00:05:54 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-12-01 00:05:54 +0100
commit370d4608ad9b534dc1e16c768e0b64ce9bf1ba5a (patch)
treef355225883d92de9f05f2af3c9688989481fdad0
parentEmbedding and attachements. (diff)
downloadmu4web-370d4608ad9b534dc1e16c768e0b64ce9bf1ba5a.tar.gz
mu4web-370d4608ad9b534dc1e16c768e0b64ce9bf1ba5a.tar.xz
Sugest download for unknown filetypes.
-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},