|
|
|
@ -369,28 +369,31 @@ var RDB = require('./redis.js'),
|
|
|
|
|
var imgur = require('./imgur');
|
|
|
|
|
imgur.setClientID(meta.config.imgurClientID);
|
|
|
|
|
|
|
|
|
|
var uploadedImages = [];
|
|
|
|
|
if(!images)
|
|
|
|
|
return callback(null, []);
|
|
|
|
|
|
|
|
|
|
var uploadedImages = images.filter(function(image) { return !!image.url; });
|
|
|
|
|
|
|
|
|
|
function uploadImage(image, next) {
|
|
|
|
|
if(!image.data)
|
|
|
|
|
return next(null);
|
|
|
|
|
|
|
|
|
|
function uploadImage(image, callback) {
|
|
|
|
|
imgur.upload(image.data, 'base64', function(err, data) {
|
|
|
|
|
if(err) {
|
|
|
|
|
callback(err);
|
|
|
|
|
next(err);
|
|
|
|
|
} else {
|
|
|
|
|
if(data.success) {
|
|
|
|
|
var img= {url:data.data.link, name:image.name};
|
|
|
|
|
uploadedImages.push(img);
|
|
|
|
|
callback(null);
|
|
|
|
|
next(null);
|
|
|
|
|
} else {
|
|
|
|
|
winston.error('Can\'t upload image, did you set imgurClientID?');
|
|
|
|
|
callback(data);
|
|
|
|
|
next(data);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!images) {
|
|
|
|
|
callback(null, uploadedImages);
|
|
|
|
|
} else {
|
|
|
|
|
async.each(images, uploadImage, function(err) {
|
|
|
|
|
if(!err) {
|
|
|
|
|
Posts.setPostField(pid, 'uploadedImages', JSON.stringify(uploadedImages));
|
|
|
|
@ -401,7 +404,6 @@ var RDB = require('./redis.js'),
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Posts.getPostsByUid = function(uid, start, end, callback) {
|
|
|
|
|
|
|
|
|
|