mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 02:36:16 +01:00
Merge branch 'master' into develop
This commit is contained in:
@@ -8,7 +8,6 @@ var events = require('../../events');
|
||||
var plugins = require('../../plugins');
|
||||
|
||||
module.exports = function (SocketUser) {
|
||||
|
||||
SocketUser.banUsers = function (socket, data, callback) {
|
||||
if (!data || !Array.isArray(data.uids)) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
@@ -24,7 +23,7 @@ module.exports = function (SocketUser) {
|
||||
type: 'user-ban',
|
||||
uid: socket.uid,
|
||||
targetUid: uid,
|
||||
ip: socket.ip
|
||||
ip: socket.ip,
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
@@ -32,10 +31,10 @@ module.exports = function (SocketUser) {
|
||||
callerUid: socket.uid,
|
||||
ip: socket.ip,
|
||||
uid: uid,
|
||||
until: data.until > 0 ? data.until : undefined
|
||||
until: data.until > 0 ? data.until : undefined,
|
||||
});
|
||||
next();
|
||||
}
|
||||
},
|
||||
], next);
|
||||
}, callback);
|
||||
};
|
||||
@@ -51,17 +50,17 @@ module.exports = function (SocketUser) {
|
||||
type: 'user-unban',
|
||||
uid: socket.uid,
|
||||
targetUid: uid,
|
||||
ip: socket.ip
|
||||
ip: socket.ip,
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
plugins.fireHook('action:user.unbanned', {
|
||||
callerUid: socket.uid,
|
||||
ip: socket.ip,
|
||||
uid: uid
|
||||
uid: uid,
|
||||
});
|
||||
next();
|
||||
}
|
||||
},
|
||||
], next);
|
||||
}, callback);
|
||||
};
|
||||
@@ -80,7 +79,7 @@ module.exports = function (SocketUser) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
async.each(uids, method, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
@@ -98,7 +97,7 @@ module.exports = function (SocketUser) {
|
||||
function (next) {
|
||||
websockets.in('uid_' + uid).emit('event:banned');
|
||||
next();
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -9,7 +9,6 @@ var user = require('../../user');
|
||||
var plugins = require('../../plugins');
|
||||
|
||||
module.exports = function (SocketUser) {
|
||||
|
||||
SocketUser.changePicture = function (socket, data, callback) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:invalid-uid]]'));
|
||||
@@ -26,31 +25,31 @@ module.exports = function (SocketUser) {
|
||||
user.isAdminOrGlobalModOrSelf(socket.uid, data.uid, next);
|
||||
},
|
||||
function (next) {
|
||||
switch(type) {
|
||||
case 'default':
|
||||
next(null, '');
|
||||
break;
|
||||
case 'uploaded':
|
||||
user.getUserField(data.uid, 'uploadedpicture', next);
|
||||
break;
|
||||
default:
|
||||
plugins.fireHook('filter:user.getPicture', {
|
||||
uid: socket.uid,
|
||||
type: type,
|
||||
picture: undefined
|
||||
}, function (err, returnData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
switch (type) {
|
||||
case 'default':
|
||||
next(null, '');
|
||||
break;
|
||||
case 'uploaded':
|
||||
user.getUserField(data.uid, 'uploadedpicture', next);
|
||||
break;
|
||||
default:
|
||||
plugins.fireHook('filter:user.getPicture', {
|
||||
uid: socket.uid,
|
||||
type: type,
|
||||
picture: undefined,
|
||||
}, function (err, returnData) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
next(null, returnData.picture || '');
|
||||
});
|
||||
break;
|
||||
next(null, returnData.picture || '');
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
function (picture, next) {
|
||||
user.setUserField(data.uid, 'picture', picture, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -67,7 +66,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (uploadedImage, next) {
|
||||
next(null, uploadedImage ? uploadedImage.url : null);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -97,12 +96,12 @@ module.exports = function (SocketUser) {
|
||||
|
||||
user.setUserFields(data.uid, {
|
||||
uploadedpicture: '',
|
||||
picture: userData.uploadedpicture === userData.picture ? '' : userData.picture // if current picture is uploaded picture, reset to user icon
|
||||
picture: userData.uploadedpicture === userData.picture ? '' : userData.picture, // if current picture is uploaded picture, reset to user icon
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
plugins.fireHook('action:user.removeUploadedPicture', {callerUid: socket.uid, uid: data.uid}, next);
|
||||
}
|
||||
plugins.fireHook('action:user.removeUploadedPicture', { callerUid: socket.uid, uid: data.uid }, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -114,9 +113,9 @@ module.exports = function (SocketUser) {
|
||||
async.parallel({
|
||||
list: async.apply(plugins.fireHook, 'filter:user.listPictures', {
|
||||
uid: data.uid,
|
||||
pictures: []
|
||||
pictures: [],
|
||||
}),
|
||||
uploaded: async.apply(user.getUserField, data.uid, 'uploadedpicture')
|
||||
uploaded: async.apply(user.getUserField, data.uid, 'uploadedpicture'),
|
||||
}, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -126,11 +125,11 @@ module.exports = function (SocketUser) {
|
||||
data.list.pictures.push({
|
||||
type: 'uploaded',
|
||||
url: data.uploaded,
|
||||
text: '[[user:uploaded_picture]]'
|
||||
text: '[[user:uploaded_picture]]',
|
||||
});
|
||||
}
|
||||
|
||||
callback(null, data.list.pictures);
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@ var events = require('../../events');
|
||||
var privileges = require('../../privileges');
|
||||
|
||||
module.exports = function (SocketUser) {
|
||||
|
||||
SocketUser.changeUsernameEmail = function (socket, data, callback) {
|
||||
if (!data || !data.uid || !socket.uid) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
@@ -20,7 +19,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (next) {
|
||||
SocketUser.updateProfile(socket, data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -34,10 +33,10 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (next) {
|
||||
user.updateCoverPicture(data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
|
||||
SocketUser.uploadCroppedPicture = function (socket, data, callback) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:no-privileges]]'));
|
||||
@@ -48,7 +47,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (next) {
|
||||
user.uploadCroppedPicture(data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -63,7 +62,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (next) {
|
||||
user.removeCoverPicture(data, next);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -77,7 +76,7 @@ module.exports = function (SocketUser) {
|
||||
} else {
|
||||
next(null, false);
|
||||
}
|
||||
}
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -114,7 +113,7 @@ module.exports = function (SocketUser) {
|
||||
type: 'password-change',
|
||||
uid: socket.uid,
|
||||
targetUid: data.uid,
|
||||
ip: socket.ip
|
||||
ip: socket.ip,
|
||||
});
|
||||
callback();
|
||||
});
|
||||
@@ -146,7 +145,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
canEdit: function (next) {
|
||||
privileges.users.canEdit(socket.uid, data.uid, next);
|
||||
}
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
@@ -175,17 +174,15 @@ module.exports = function (SocketUser) {
|
||||
}
|
||||
|
||||
if (userData.email !== oldUserData.email) {
|
||||
log('email-change', {oldEmail: oldUserData.email, newEmail: userData.email});
|
||||
log('email-change', { oldEmail: oldUserData.email, newEmail: userData.email });
|
||||
}
|
||||
|
||||
if (userData.username !== oldUserData.username) {
|
||||
log('username-change', {oldUsername: oldUserData.username, newUsername: userData.username});
|
||||
log('username-change', { oldUsername: oldUserData.username, newUsername: userData.username });
|
||||
}
|
||||
|
||||
next(null, userData);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -5,7 +5,6 @@ var meta = require('../../meta');
|
||||
var pagination = require('../../pagination');
|
||||
|
||||
module.exports = function (SocketUser) {
|
||||
|
||||
SocketUser.search = function (socket, data, callback) {
|
||||
if (!data) {
|
||||
return callback(new Error('[[error:invalid-data]]'));
|
||||
@@ -21,7 +20,7 @@ module.exports = function (SocketUser) {
|
||||
onlineOnly: data.onlineOnly,
|
||||
bannedOnly: data.bannedOnly,
|
||||
flaggedOnly: data.flaggedOnly,
|
||||
uid: socket.uid
|
||||
uid: socket.uid,
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -31,5 +30,4 @@ module.exports = function (SocketUser) {
|
||||
callback(null, result);
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -6,7 +6,6 @@ var user = require('../../user');
|
||||
var websockets = require('../index');
|
||||
|
||||
module.exports = function (SocketUser) {
|
||||
|
||||
SocketUser.checkStatus = function (socket, uid, callback) {
|
||||
if (!socket.uid) {
|
||||
return callback(new Error('[[error:invalid-uid]]'));
|
||||
@@ -17,7 +16,7 @@ module.exports = function (SocketUser) {
|
||||
},
|
||||
function (userData, next) {
|
||||
next(null, user.getStatus(userData));
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
@@ -31,7 +30,7 @@ module.exports = function (SocketUser) {
|
||||
return callback(new Error('[[error:invalid-user-status]]'));
|
||||
}
|
||||
|
||||
var data = {status: status};
|
||||
var data = { status: status };
|
||||
if (status !== 'offline') {
|
||||
data.lastonline = Date.now();
|
||||
}
|
||||
@@ -43,11 +42,11 @@ module.exports = function (SocketUser) {
|
||||
function (next) {
|
||||
var data = {
|
||||
uid: socket.uid,
|
||||
status: status
|
||||
status: status,
|
||||
};
|
||||
websockets.server.emit('event:user_status_change', data);
|
||||
next(null, data);
|
||||
}
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user