[local-sync]: Fix label/folder id creation

We were using the stripped version of label/folder names for the id
hash, e.g. [Gmail]/Drafts would be Drafts.
However, we can't do this because it might collide with other names. e.g. if the
user created a Drafts label, it would end up colliding with [Gmail]/Drafts

Minor lint fix
This commit is contained in:
Juan Tejada 2016-12-07 13:39:41 -08:00
parent edbf869ff7
commit 8307976df8
4 changed files with 4 additions and 5 deletions

View file

@ -1,6 +1,7 @@
const _ = require('underscore');
const os = require('os');
const fs = require('fs');
const path = require('path')
const mkdirp = require('mkdirp');
const {PromiseUtils, IMAPConnection} = require('isomorphic-core');

View file

@ -28,8 +28,7 @@ module.exports = (sequelize, Sequelize) => {
},
hash({boxName, accountId}) {
const cleanName = formatImapPath(boxName)
return crypto.createHash('sha256').update(`${accountId}${cleanName}`, 'utf8').digest('hex')
return crypto.createHash('sha256').update(`${accountId}${boxName}`, 'utf8').digest('hex')
},
},
instanceMethods: {

View file

@ -43,8 +43,7 @@ module.exports = (sequelize, Sequelize) => {
},
hash({boxName, accountId}) {
const cleanName = formatImapPath(boxName)
return crypto.createHash('sha256').update(`${accountId}${cleanName}`, 'utf8').digest('hex')
return crypto.createHash('sha256').update(`${accountId}${boxName}`, 'utf8').digest('hex')
},
},
instanceMethods: {

View file

@ -28,10 +28,10 @@ async function extractContacts({db, message}) {
const id = cryptography.createHash('sha256').update(c.email, 'utf8').digest('hex');
const existing = await db.Contact.findById(id);
const cdata = {
id,
name: c.name,
email: c.email,
accountId: message.accountId,
id: id,
};
if (!existing) {