diff options
author | Robin Jarry <robin@jarry.cc> | 2022-10-12 23:52:45 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-10-16 11:35:24 +0200 |
commit | 9bd2e0c84fef66007bcab027883c01414b99b77c (patch) | |
tree | 515414d5d8d95f2360bd1e9db31ef7fdca7cdd86 /lib | |
parent | a4b80bcc8b4427016bfb0c2924ffaa9f8b90916d (diff) | |
download | aerc-9bd2e0c84fef66007bcab027883c01414b99b77c.tar.gz |
msgpart: factorize mime type and filename construction
Reduce code duplication.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/structure_helpers.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/structure_helpers.go b/lib/structure_helpers.go index 6f25e459..0189dc8a 100644 --- a/lib/structure_helpers.go +++ b/lib/structure_helpers.go @@ -9,8 +9,7 @@ import ( func FindPlaintext(bs *models.BodyStructure, path []int) []int { for i, part := range bs.Parts { cur := append(path, i+1) //nolint:gocritic // intentional append to different slice - if strings.ToLower(part.MIMEType) == "text" && - strings.ToLower(part.MIMESubType) == "plain" { + if part.FullMIMEType() == "text/plain" { return cur } if strings.ToLower(part.MIMEType) == "multipart" { @@ -25,8 +24,7 @@ func FindPlaintext(bs *models.BodyStructure, path []int) []int { func FindCalendartext(bs *models.BodyStructure, path []int) []int { for i, part := range bs.Parts { cur := append(path, i+1) //nolint:gocritic // intentional append to different slice - if strings.ToLower(part.MIMEType) == "text" && - strings.ToLower(part.MIMESubType) == "calendar" { + if part.FullMIMEType() == "text/calendar" { return cur } if strings.ToLower(part.MIMEType) == "multipart" { |