fix(GODT-2851): Add empty text part if no text part when importing multipart.

This commit is contained in:
Romain LE JEUNE
2023-11-30 09:41:52 +01:00
parent 1b22c32ef9
commit 38606888fe
5 changed files with 160 additions and 32 deletions

View File

@ -84,7 +84,7 @@ func (p *Parser) AttachPublicKey(key, keyName string) {
})
}
func (p *Parser) AttachEmptyTextPartIfNoneExists() {
func (p *Parser) AttachEmptyTextPartIfNoneExists() bool {
root := p.Root()
if root.isMultipartMixed() {
for _, v := range root.children {
@ -95,14 +95,14 @@ func (p *Parser) AttachEmptyTextPartIfNoneExists() {
contentType, _, err := v.Header.ContentType()
if err == nil && strings.HasPrefix(contentType, "text/") {
// Message already has text part
return
return false
}
}
} else {
contentType, _, err := root.Header.ContentType()
if err == nil && strings.HasPrefix(contentType, "text/") {
// Message already has text part
return
return false
}
}
@ -115,6 +115,7 @@ func (p *Parser) AttachEmptyTextPartIfNoneExists() {
Header: h,
Body: nil,
})
return true
}
// Section returns the message part referred to by the given section. A section