v1.18.x
barisusakli 10 years ago
parent 595ff1f4b1
commit 39b679705b

@ -428,7 +428,7 @@ accountsController.uploadPicture = function (req, res, next) {
});
}
var updateUid = req.user.uid;
var updateUid = req.user ? req.user.uid : 0;
var imageDimension = parseInt(meta.config.profileImageDimension, 10) || 128;
async.waterfall([
@ -483,7 +483,7 @@ accountsController.uploadPicture = function (req, res, next) {
}
if (plugins.hasListeners('filter:uploadImage')) {
return plugins.fireHook('filter:uploadImage', req.files.userPhoto, done);
return plugins.fireHook('filter:uploadImage', {image: req.files.userPhoto, uid: updateUid}, done);
}
var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10) === 1;

@ -2,8 +2,8 @@
var fs = require('fs'),
path = require('path'),
file = require('./../../file'),
plugins = require('./../../plugins');
file = require('../../file'),
plugins = require('../../plugins');
var uploadsController = {};
@ -37,7 +37,7 @@ uploadsController.uploadImage = function(filename, folder, req, res) {
}
if (plugins.hasListeners('filter:uploadImage')) {
plugins.fireHook('filter:uploadImage', req.files.userPhoto, done);
plugins.fireHook('filter:uploadImage', {image: req.files.userPhoto, uid: req.user.uid}, done);
} else {
file.saveFileToLocal(filename, folder, req.files.userPhoto.path, done);
}

@ -55,7 +55,7 @@ function upload(req, res, filesIterator, next) {
function uploadPost(req, res, next) {
upload(req, res, function(file, next) {
if(file.type.match(/image./)) {
uploadImage(file, next);
uploadImage(req.user.uid, file, next);
} else {
uploadFile(file, next);
}
@ -75,7 +75,7 @@ function uploadThumb(req, res, next) {
if (err) {
return next(err);
}
uploadImage(file, next);
uploadImage(req.user.uid, file, next);
});
} else {
next(new Error('[[error:invalid-file]]'));
@ -84,22 +84,22 @@ function uploadThumb(req, res, next) {
}
function uploadImage(image, callback) {
function uploadImage(uid, image, callback) {
if (plugins.hasListeners('filter:uploadImage')) {
plugins.fireHook('filter:uploadImage', image, callback);
plugins.fireHook('filter:uploadImage', {image: image, uid: uid}, callback);
} else {
if (parseInt(meta.config.allowFileUploads, 10)) {
uploadFile(image, callback);
uploadFile(uid, image, callback);
} else {
callback(new Error('[[error:uploads-are-disabled]]'));
}
}
}
function uploadFile(file, callback) {
function uploadFile(uid, file, callback) {
if (plugins.hasListeners('filter:uploadFile')) {
plugins.fireHook('filter:uploadFile', file, callback);
plugins.fireHook('filter:uploadFile', {file: file, uid: uid}, callback);
} else {
if(parseInt(meta.config.allowFileUploads, 10) !== 1) {

@ -199,7 +199,7 @@ SocketUser.uploadProfileImageFromUrl = function(socket, url, callback) {
return;
}
plugins.fireHook('filter:uploadImage', {url: url}, function(err, image) {
plugins.fireHook('filter:uploadImage', {image: {url: url}, uid: socket.uid}, function(err, image) {
if (err) {
return callback(err);
}

Loading…
Cancel
Save