feat: change uploadCroppedPicture to use updateProfile as well

v1.18.x
Barış Soner Uşaklı 4 years ago
parent a598abcd8e
commit 0af9d26fe5

@ -36,6 +36,7 @@ module.exports = function (SocketUser) {
}
await user.isAdminOrGlobalModOrSelf(socket.uid, data.uid);
await user.checkMinReputation(socket.uid, data.uid, 'min:rep:profile-picture');
data.callerUid = socket.uid;
return await user.uploadCroppedPicture(data);
};

@ -148,10 +148,11 @@ module.exports = function (User) {
const uploadedImage = await image.uploadImage(filename, 'profile', picture);
await deleteCurrentPicture(data.uid, 'uploadedpicture');
await User.setUserFields(data.uid, {
await User.updateProfile(data.callerUid, {
uid: data.uid,
uploadedpicture: uploadedImage.url,
picture: uploadedImage.url,
});
}, ['uploadedpicture', 'picture']);
return uploadedImage;
} finally {
await file.delete(picture.path);

@ -1156,6 +1156,7 @@ describe('User', () => {
type: 'image/png',
};
User.uploadCroppedPicture({
callerUid: uid,
uid: uid,
file: picture,
}, (err) => {
@ -1167,6 +1168,7 @@ describe('User', () => {
it('should return error if profile image has no mime type', (done) => {
User.uploadCroppedPicture({
callerUid: uid,
uid: uid,
imageData: 'data:image/invalid;base64,R0lGODlhPQBEAPeoAJosM/',
}, (err) => {
@ -1189,6 +1191,7 @@ describe('User', () => {
const temp = meta.config.maximumProfileImageSize;
meta.config.maximumProfileImageSize = 1;
User.uploadCroppedPicture({
callerUid: uid,
uid: 1,
imageData: goodImage,
}, (err) => {
@ -1202,6 +1205,7 @@ describe('User', () => {
it('should not allow image data with bad MIME type to be passed in', (done) => {
User.uploadCroppedPicture({
callerUid: uid,
uid: 1,
imageData: badImage,
}, (err) => {

Loading…
Cancel
Save