imap: strip <> from message-ids

This commit is contained in:
Reto Brunner 2020-11-08 14:18:14 +01:00
parent 18b0ea571a
commit daf214a1f8
1 changed files with 9 additions and 1 deletions

View File

@ -48,6 +48,14 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
return nil return nil
} }
// we strip the msgid of "<>" in order to be more compatible with go-message
// which wants to handle msgids without the markers
// note this is a very naive way of doing it but probably good enough
msgID := e.MessageId
if len(msgID) > 1 && msgID[0] == '<' && msgID[len(msgID)-1] == '>' {
msgID = msgID[1 : len(msgID)-1]
}
return &models.Envelope{ return &models.Envelope{
Date: e.Date, Date: e.Date,
Subject: e.Subject, Subject: e.Subject,
@ -56,7 +64,7 @@ func translateEnvelope(e *imap.Envelope) *models.Envelope {
To: translateAddresses(e.To), To: translateAddresses(e.To),
Cc: translateAddresses(e.Cc), Cc: translateAddresses(e.Cc),
Bcc: translateAddresses(e.Bcc), Bcc: translateAddresses(e.Bcc),
MessageId: e.MessageId, MessageId: msgID,
} }
} }