added a hook to post image upload for starters, more coming

v1.18.x
Baris Soner Usakli 11 years ago
parent c78942b7a4
commit 0f2e7fa8bd

@ -396,25 +396,30 @@ var db = require('./database'),
Posts.uploadPostImage = function(image, callback) { Posts.uploadPostImage = function(image, callback) {
if(meta.config.imgurClientID) { if(plugins.hasListeners('filter:post.upload')) {
if(!image || !image.data) { plugins.fireHook('filter:post.upload', image, callback);
return callback(new Error('invalid image')); } else {
}
require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) { if(meta.config.imgurClientID) {
if(err) { if(!image || !image.data) {
return callback(err); return callback(new Error('invalid image'));
} }
callback(null, { require('./imgur').upload(meta.config.imgurClientID, image.data, 'base64', function(err, data) {
url: data.link, if(err) {
name: image.name return callback(err);
}
callback(null, {
url: data.link,
name: image.name
});
}); });
}); } else if (meta.config.allowFileUploads) {
} else if (meta.config.allowFileUploads) { Posts.uploadPostFile(image, callback);
Posts.uploadPostFile(image, callback); } else {
} else { callback(new Error('Uploads are disabled!'));
callback(new Error('Uploads are disabled!')); }
} }
} }

Loading…
Cancel
Save