aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
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
parentd66930749a9f8eaa19acab78d57585a170f17429 (diff)
downloadaerc-d64ceba2cc8d8d1624348a76c7e7a02e385e6d0a.tar.gz
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')
-rw-r--r--widgets/msgviewer.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go
index 91baf025..cefa9bb3 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 {