can edit and add an image to a post, still cant remove previously added images #issue #233

This commit is contained in:
Baris Soner Usakli
2013-08-29 21:18:23 -04:00
parent 928594fc7c
commit 54ba6efc93
5 changed files with 29 additions and 9 deletions

View File

@@ -55,7 +55,7 @@ var RDB = require('./redis.js'),
});
}
PostTools.edit = function(uid, pid, title, content) {
PostTools.edit = function(uid, pid, title, content, images) {
var success = function() {
posts.setPostField(pid, 'content', content);
posts.setPostField(pid, 'edited', Date.now());
@@ -66,6 +66,11 @@ var RDB = require('./redis.js'),
});
async.parallel([
function(next) {
posts.uploadPostImages(pid, images, function(err, uploadedImages) {
next(err, uploadedImages);
});
},
function(next) {
posts.getPostField(pid, 'tid', function(tid) {
PostTools.isMain(pid, tid, function(isMainPost) {
@@ -76,7 +81,7 @@ var RDB = require('./redis.js'),
});
}
next(null, tid);
next(null, {tid:tid, isMainPost:isMainPost});
});
});
},
@@ -84,10 +89,12 @@ var RDB = require('./redis.js'),
PostTools.toHTML(content, next);
}
], function(err, results) {
io.sockets.in('topic_' + results[0]).emit('event:post_edited', {
io.sockets.in('topic_' + results[1].tid).emit('event:post_edited', {
pid: pid,
title: title,
content: results[1]
isMainPost: results[1].isMainPost,
content: results[2],
uploadedImages:results[0]
});
});
};