mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 03:23:45 +08:00
fix(message-ids): Use correct hashing for headers
This commit is contained in:
parent
fae855f0fe
commit
6e111c073a
1 changed files with 15 additions and 15 deletions
|
@ -17,8 +17,21 @@ function extractContacts(values = []) {
|
|||
})
|
||||
}
|
||||
|
||||
function getHeadersForId(data) {
|
||||
let participants = "";
|
||||
const emails = _.pluck(data.from.concat(data.to, data.cc, data.bcc), 'email');
|
||||
emails.sort().forEach((email) => {
|
||||
participants += email
|
||||
});
|
||||
return `${data.date}-${data.subject}-${participants}`;
|
||||
}
|
||||
|
||||
function hashForHeaders(headers) {
|
||||
return cryptography.createHash('sha256').update(headers, 'utf8').digest('hex');
|
||||
}
|
||||
|
||||
async function parseFromImap(imapMessage, desiredParts, {db, accountId, folder}) {
|
||||
const {Message, Label} = db
|
||||
const {Label} = db
|
||||
const body = {}
|
||||
const {headers, attributes} = imapMessage
|
||||
const xGmLabels = attributes['x-gm-labels']
|
||||
|
@ -43,7 +56,7 @@ async function parseFromImap(imapMessage, desiredParts, {db, accountId, folder})
|
|||
}
|
||||
|
||||
const values = {
|
||||
id: Message.hashForHeaders(headers),
|
||||
id: hashForHeaders(getHeadersForId(parsedHeaders)),
|
||||
to: extractContacts(parsedHeaders.to),
|
||||
cc: extractContacts(parsedHeaders.cc),
|
||||
bcc: extractContacts(parsedHeaders.bcc),
|
||||
|
@ -92,19 +105,6 @@ async function parseFromImap(imapMessage, desiredParts, {db, accountId, folder})
|
|||
return values;
|
||||
}
|
||||
|
||||
function hashForHeaders(headers) {
|
||||
return cryptography.createHash('sha256').update(headers, 'utf8').digest('hex');
|
||||
}
|
||||
|
||||
function getHeadersForId(data) {
|
||||
let participants = "";
|
||||
const emails = _.pluck(data.from.concat(data.to, data.cc, data.bcc), 'email');
|
||||
emails.sort().forEach((email) => {
|
||||
participants += email
|
||||
});
|
||||
return `${data.date}-${data.subject}-${participants}`;
|
||||
}
|
||||
|
||||
function fromJSON(db, data) {
|
||||
// TODO: events, metadata?
|
||||
const {Message} = db;
|
||||
|
|
Loading…
Reference in a new issue