aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorVitaly Ovchinnikov <v@postbox.nz>2023-06-07 14:27:13 +0300
committerRobin Jarry <robin@jarry.cc>2023-06-10 19:58:14 +0200
commit5fc6c8408450a8a7e7b6d33632155d6aca0db9be (patch)
treef8430210630e2233b80b7a6f45d89d5c9033f3d8 /widgets/msgviewer.go
parentedd4752268b266d697be51733599b708e4ae449a (diff)
downloadaerc-5fc6c8408450a8a7e7b6d33632155d6aca0db9be.tar.gz
save: new option for saving attachments
Add a new `-A` option to `:save` that works in the same manner as `-a`, but saves all the named parts of an email, not just attachments. The reason is that I have an email with this structure: multipart/related multipart/alternative text/plain text/html image/png (image001.png) image/png (image002.png) image/png (image003.png) text/plain (env.txt) Where the `env.txt` is a "real" attachment, while the images are just a part of the HTML version of the email. However, in this particular email it was important to see them which can't be done with text UI and opening the HTML part with the browser also didn't work. Saving them to a temorary folder did the job and this can be useful in other scenarios. So before the patch we could do `:save -ap /some/path` and get just the `env.txt` saved there. After the patch we could also do `:save -Ap /some/path` and get all the images and the text file saved into the folder. Signed-off-by: Vitaly Ovchinnikov <v@postbox.nz> Tested-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 6752fbff..bb30734d 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -337,11 +337,11 @@ func (mv *MessageViewer) SelectedMessagePart() *PartInfo {
}
}
-func (mv *MessageViewer) AttachmentParts() []*PartInfo {
+func (mv *MessageViewer) AttachmentParts(all bool) []*PartInfo {
var attachments []*PartInfo
for _, p := range mv.switcher.parts {
- if p.part.Disposition == "attachment" {
+ if p.part.Disposition == "attachment" || (all && p.part.FileName() != "") {
pi := &PartInfo{
Index: p.index,
Msg: p.msg.MessageInfo(),