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. --- commands/msg/utils.go | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'commands/msg/utils.go') diff --git a/commands/msg/utils.go b/commands/msg/utils.go index 5eb5fe5..cad0f82 100644 --- a/commands/msg/utils.go +++ b/commands/msg/utils.go @@ -2,7 +2,6 @@ package msg import ( "errors" - "strings" "git.sr.ht/~sircmpwn/aerc/commands" "git.sr.ht/~sircmpwn/aerc/lib" @@ -49,34 +48,3 @@ func (h *helper) messages() ([]*models.MessageInfo, error) { } return commands.MsgInfoFromUids(store, uid) } - -func findPlaintext(bs *models.BodyStructure, path []int) []int { - for i, part := range bs.Parts { - cur := append(path, i+1) - if strings.ToLower(part.MIMEType) == "text" && - strings.ToLower(part.MIMESubType) == "plain" { - return cur - } - if strings.ToLower(part.MIMEType) == "multipart" { - if path := findPlaintext(part, cur); path != nil { - return path - } - } - } - return nil -} - -func findFirstNonMultipart(bs *models.BodyStructure, path []int) []int { - for i, part := range bs.Parts { - cur := append(path, i+1) - mimetype := strings.ToLower(part.MIMEType) - if mimetype != "multipart" { - return path - } else if mimetype == "multipart" { - if path := findPlaintext(part, cur); path != nil { - return path - } - } - } - return nil -} -- cgit 1.4.1-2-gfad0