diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-06 21:22:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-06 21:22:04 +0200 |
commit | a894efcaced8b1e2e330c13d4e8f2d07d3ae814b (patch) | |
tree | 3fe89cf8c8b92bf1213c64c57b7ccafc67b5bc89 /common | |
parent | 0d5e1e431131558a04bf42c4850c8721414294d3 (diff) | |
download | sink-a894efcaced8b1e2e330c13d4e8f2d07d3ae814b.tar.gz sink-a894efcaced8b1e2e330c13d4e8f2d07d3ae814b.zip |
Avoid regenerating the messageId on every modfication
Diffstat (limited to 'common')
-rw-r--r-- | common/mailpreprocessor.cpp | 22 |
1 files 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: | |||
104 | mail.setExtractedBcc(getContactList(msg->bcc(true))); | 104 | mail.setExtractedBcc(getContactList(msg->bcc(true))); |
105 | mail.setExtractedDate(msg->date(true)->dateTime()); | 105 | mail.setExtractedDate(msg->date(true)->dateTime()); |
106 | 106 | ||
107 | //The rest should never change, unless we didn't have the headers available initially. | ||
108 | auto messageId = msg->messageID(true)->identifier(); | ||
109 | |||
110 | //Ensure the mssageId is unique. | 107 | //Ensure the mssageId is unique. |
111 | //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. | 108 | //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. |
112 | 109 | ||
@@ -125,12 +122,21 @@ static void updatedIndexedProperties(Sink::ApplicationDomain::Mail &mail, KMime: | |||
125 | parentMessageId = inReplyTo.first(); | 122 | parentMessageId = inReplyTo.first(); |
126 | } | 123 | } |
127 | } | 124 | } |
125 | |||
126 | //The rest should never change, unless we didn't have the headers available initially. | ||
127 | auto messageId = msg->messageID(true)->identifier(); | ||
128 | if (messageId.isEmpty()) { | 128 | if (messageId.isEmpty()) { |
129 | auto tmp = KMime::Message::Ptr::create(); | 129 | //reuse an existing messageis (on modification) |
130 | auto header = tmp->messageID(true); | 130 | auto existing = mail.getMessageId(); |
131 | header->generate("kube.kde.org"); | 131 | if (existing.isEmpty()) { |
132 | messageId = header->as7BitString(); | 132 | auto tmp = KMime::Message::Ptr::create(); |
133 | SinkWarning() << "Message id is empty, generating one: " << messageId; | 133 | auto header = tmp->messageID(true); |
134 | header->generate("kube.kde.org"); | ||
135 | messageId = header->as7BitString(); | ||
136 | SinkWarning() << "Message id is empty, generating one: " << messageId; | ||
137 | } else { | ||
138 | messageId = existing; | ||
139 | } | ||
134 | } | 140 | } |
135 | 141 | ||
136 | mail.setExtractedMessageId(messageId); | 142 | mail.setExtractedMessageId(messageId); |