[local-sync]: Add distinct ids to folders and labels

This commit is contained in:
Juan Tejada 2016-12-01 11:57:23 -08:00
parent 209122c346
commit 8939364dc3
5 changed files with 7 additions and 3 deletions

View file

@ -72,7 +72,7 @@ module.exports = (server) => {
tags: [term],
validate: {
params: {
id: Joi.number().integer(),
id: Joi.string(),
},
},
response: {

View file

@ -35,7 +35,7 @@ function jsonSchema(modelName) {
}
if (modelName === 'Folder') {
return Joi.object().keys({
id: Joi.number(),
id: Joi.string(),
object: Joi.string(),
account_id: Joi.string(),
name: Joi.string().allow(null),
@ -44,7 +44,7 @@ function jsonSchema(modelName) {
}
if (modelName === 'Label') {
return Joi.object().keys({
id: Joi.number(),
id: Joi.string(),
object: Joi.string(),
account_id: Joi.string(),
name: Joi.string().allow(null),

View file

@ -1,3 +1,4 @@
const crypto = require('crypto')
const {Provider, PromiseUtils} = require('isomorphic-core');
const {localizedCategoryNames} = require('../sync-utils')
@ -93,6 +94,7 @@ class FetchFolderList {
const role = this._roleByAttr(box);
const Klass = this._classForMailboxWithRole(role, this._db);
category = Klass.build({
id: crypto.createHash('sha256').update(boxName, 'utf8').digest('hex'),
name: boxName,
accountId: this._db.accountId,
role: role,

View file

@ -2,6 +2,7 @@ const {DatabaseTypes: {JSONType}} = require('isomorphic-core');
module.exports = (sequelize, Sequelize) => {
return sequelize.define('folder', {
id: { type: Sequelize.STRING(65), primaryKey: true },
accountId: { type: Sequelize.STRING, allowNull: false },
version: Sequelize.INTEGER,
name: Sequelize.STRING,

View file

@ -1,5 +1,6 @@
module.exports = (sequelize, Sequelize) => {
return sequelize.define('label', {
id: { type: Sequelize.STRING(65), primaryKey: true },
accountId: { type: Sequelize.STRING, allowNull: false },
version: Sequelize.INTEGER,
name: Sequelize.STRING,