|
|
|
@ -269,14 +269,9 @@ module.exports = function(Posts) {
|
|
|
|
|
|
|
|
|
|
// Track new additions
|
|
|
|
|
for(prop in flagObj) {
|
|
|
|
|
if (flagObj.hasOwnProperty(prop) && !postData.hasOwnProperty('flag:' + prop)) {
|
|
|
|
|
if (flagObj.hasOwnProperty(prop) && !postData.hasOwnProperty('flag:' + prop) && flagObj[prop].length) {
|
|
|
|
|
changes.push(prop);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate changeset for object modification
|
|
|
|
|
if (flagObj.hasOwnProperty(prop)) {
|
|
|
|
|
changeset['flag:' + prop] = flagObj[prop];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Track changed items
|
|
|
|
@ -290,6 +285,11 @@ module.exports = function(Posts) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changeset = changes.reduce(function(memo, prop) {
|
|
|
|
|
memo['flag:' + prop] = flagObj[prop];
|
|
|
|
|
return memo;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
// Append changes to history string
|
|
|
|
|
if (changes.length) {
|
|
|
|
|
try {
|
|
|
|
@ -323,7 +323,11 @@ module.exports = function(Posts) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save flag data into post hash
|
|
|
|
|
Posts.setPostFields(pid, changeset, callback);
|
|
|
|
|
if (changes.length) {
|
|
|
|
|
Posts.setPostFields(pid, changeset, callback);
|
|
|
|
|
} else {
|
|
|
|
|
setImmediate(callback);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|