WIP post diffs

This commit is contained in:
Julian Lam
2018-02-16 16:41:06 -05:00
parent 55788382ea
commit 501fc3cee9
6 changed files with 72 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ module.exports = function (Posts) {
});
Posts.edit = function (data, callback) {
var oldContent; // for diffing purposes
var postData;
var results;
@@ -39,6 +40,7 @@ module.exports = function (Posts) {
}
postData = _postData;
oldContent = postData.content;
postData.content = data.content;
postData.edited = Date.now();
postData.editor = data.uid;
@@ -63,6 +65,9 @@ module.exports = function (Posts) {
results = _results;
Posts.setPostFields(data.pid, postData, next);
},
function (next) {
Posts.diffs.save(data.pid, oldContent, data.content, next);
},
function (next) {
postData.cid = results.topic.cid;
postData.topic = results.topic;