From a894efcaced8b1e2e330c13d4e8f2d07d3ae814b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 6 Jul 2017 21:22:04 +0200 Subject: Avoid regenerating the messageId on every modfication --- common/mailpreprocessor.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/common/mailpreprocessor.cpp b/common/mailpreprocessor.cpp index 5c54fbc..253e8b4 100644 --- a/common/mailpreprocessor.cpp +++ b/common/mailpreprocessor.cpp @@ -104,9 +104,6 @@ static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime: mail.setExtractedBcc(getContactList(msg->bcc(true))); mail.setExtractedDate(msg->date(true)->dateTime()); - //The rest should never change, unless we didn't have the headers available initially. - auto messageId = msg->messageID(true)->identifier(); - //Ensure the mssageId is unique. //If there already is one with the same id we'd have to assign a new message id, which probably doesn't make any sense. @@ -125,12 +122,21 @@ static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime: parentMessageId = inReplyTo.first(); } } + + //The rest should never change, unless we didn't have the headers available initially. + auto messageId = msg->messageID(true)->identifier(); if (messageId.isEmpty()) { - auto tmp = KMime::Message::Ptr::create(); - auto header = tmp->messageID(true); - header->generate("kube.kde.org"); - messageId = header->as7BitString(); - SinkWarning() << "Message id is empty, generating one: " << messageId; + //reuse an existing messageis (on modification) + auto existing = mail.getMessageId(); + if (existing.isEmpty()) { + auto tmp = KMime::Message::Ptr::create(); + auto header = tmp->messageID(true); + header->generate("kube.kde.org"); + messageId = header->as7BitString(); + SinkWarning() << "Message id is empty, generating one: " << messageId; + } else { + messageId = existing; + } } mail.setExtractedMessageId(messageId); -- cgit v1.2.3