better thread matching for dsns

keep track of whether a message is a dsn, and match dsn's against their sent
message by ignoring the message subject.
This commit is contained in:
Mechiel Lukkien
2024-03-04 16:40:27 +01:00
parent f6497b1aaf
commit 13923e4b7b
9 changed files with 39 additions and 13 deletions

View File

@ -575,6 +575,15 @@ func (p *Part) ParseNextPart(elog *slog.Logger) (*Part, error) {
return &p.Parts[len(p.Parts)-1], nil
}
// IsDSN returns whether the MIME structure of the part is a DSN.
func (p *Part) IsDSN() bool {
return p.MediaType == "MULTIPART" &&
p.MediaSubType == "REPORT" &&
len(p.Parts) >= 2 &&
p.Parts[1].MediaType == "MESSAGE" &&
(p.Parts[1].MediaSubType == "DELIVERY-STATUS" || p.Parts[1].MediaSubType == "GLOBAL-DELIVERY-STATUS")
}
// Reader returns a reader for the decoded body content.
func (p *Part) Reader() io.Reader {
return p.bodyReader(p.RawReader())