From c574a838fa89bf46bf7188442f400b206b04df95 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Fri, 19 Jun 2020 17:58:08 +0200 Subject: Remove hard coded bodystruct path everywhere Aerc usually used the path []int{1} if it didn't know what the proper path is. However this only works for multipart messages and breaks if it isn't one. This patch removes all the hard coding and extracts the necessary helpers to lib. --- worker/maildir/search.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'worker/maildir') diff --git a/worker/maildir/search.go b/worker/maildir/search.go index 005f6fa..ad3a45f 100644 --- a/worker/maildir/search.go +++ b/worker/maildir/search.go @@ -10,6 +10,7 @@ import ( "git.sr.ht/~sircmpwn/getopt" + "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/models" ) @@ -138,7 +139,12 @@ func (w *Worker) searchKey(key uint32, criteria *searchCriteria, } if parts&BODY > 0 { // TODO: select which part to search, maybe look for text/plain - reader, err := message.NewBodyPartReader([]int{1}) + mi, err := message.MessageInfo() + if err != nil { + return false, err + } + path := lib.FindFirstNonMultipart(mi.BodyStructure, nil) + reader, err := message.NewBodyPartReader(path) if err != nil { return false, err } -- cgit 1.4.1-2-gfad0