save: add -a option to save all attachments

Allow saving all message parts that have the content disposition
"attachment" header to a folder.

Suggested-by: Ondřej Synáček <ondrej@synacek.org>
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Koni Marti <koni.marti@gmail.com>
Tested-by: Moritz Poldrack <moritz@poldrack.dev>
This commit is contained in:
Robin Jarry 2022-03-24 09:26:06 +01:00
commit d64ceba2cc
3 changed files with 70 additions and 19 deletions

View file

@ -303,6 +303,23 @@ func (mv *MessageViewer) SelectedMessagePart() *PartInfo {
}
}
func (mv *MessageViewer) AttachmentParts() []*PartInfo {
var attachments []*PartInfo
for _, p := range mv.switcher.parts {
if p.part.Disposition == "attachment" {
pi := &PartInfo{
Index: p.index,
Msg: p.msg.MessageInfo(),
Part: p.part,
}
attachments = append(attachments, pi)
}
}
return attachments
}
func (mv *MessageViewer) PreviousPart() {
switcher := mv.switcher
for {