summaryrefslogtreecommitdiff
path: root/widgets/msgviewer.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2022-03-24 09:26:06 +0100
committerRobin Jarry <robin@jarry.cc>2022-03-24 15:30:10 +0100
commitd64ceba2cc8d8d1624348a76c7e7a02e385e6d0a (patch)
tree70adf3aa3b2224a57be48f98905db64f0d6c6c3c /widgets/msgviewer.go
parentd66930749a9f8eaa19acab78d57585a170f17429 (diff)
downloadaerc-d64ceba2cc8d8d1624348a76c7e7a02e385e6d0a.zip
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>
Diffstat (limited to 'widgets/msgviewer.go')
-rw-r--r--widgets/msgviewer.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 91baf02..cefa9bb 100644
--- a/widgets/msgviewer.go
+++ b/widgets/msgviewer.go
@@ -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 {