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>
This commit is contained in:
parent
a4b80bcc8b
commit
9bd2e0c84f
8 changed files with 30 additions and 28 deletions
|
@ -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" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue