mirror of
https://github.com/larksuite/cli.git
synced 2026-07-07 00:55:53 +08:00
fix(mail): use consistent inline predicate and safer HTML part lookup
1. removeOrphanedInlineParts: change condition from ContentDisposition=="inline" && ContentID!="" to isInlinePart(child) && ContentID!="", matching the predicate used elsewhere — parts with only a ContentID (no Content-Disposition) are now correctly cleaned up. 2. postProcessInlineImages: use findPrimaryBodyPart instead of findPart(snapshot.Body, PrimaryHTMLPartID) to avoid stale PartID after ops restructure the MIME tree.
This commit is contained in:
@@ -966,7 +966,7 @@ func removeOrphanedInlineParts(root *Part, referencedCIDs map[string]bool) {
|
|||||||
if child == nil {
|
if child == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if strings.EqualFold(child.ContentDisposition, "inline") && child.ContentID != "" {
|
if isInlinePart(child) && child.ContentID != "" {
|
||||||
if !referencedCIDs[strings.ToLower(child.ContentID)] {
|
if !referencedCIDs[strings.ToLower(child.ContentID)] {
|
||||||
root.Dirty = true
|
root.Dirty = true
|
||||||
continue
|
continue
|
||||||
@@ -982,7 +982,7 @@ func removeOrphanedInlineParts(root *Part, referencedCIDs map[string]bool) {
|
|||||||
// 2. Validates all CID references in HTML resolve to MIME parts.
|
// 2. Validates all CID references in HTML resolve to MIME parts.
|
||||||
// 3. Removes orphaned inline MIME parts no longer referenced by HTML.
|
// 3. Removes orphaned inline MIME parts no longer referenced by HTML.
|
||||||
func postProcessInlineImages(snapshot *DraftSnapshot) error {
|
func postProcessInlineImages(snapshot *DraftSnapshot) error {
|
||||||
htmlPart := findPart(snapshot.Body, snapshot.PrimaryHTMLPartID)
|
htmlPart := findPrimaryBodyPart(snapshot.Body, "text/html")
|
||||||
if htmlPart == nil {
|
if htmlPart == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user