|
|
@ -6,6 +6,7 @@ var nconf = require('nconf');
|
|
|
|
var winston = require('winston');
|
|
|
|
var winston = require('winston');
|
|
|
|
|
|
|
|
|
|
|
|
var db = require('../database');
|
|
|
|
var db = require('../database');
|
|
|
|
|
|
|
|
var meta = require('../meta');
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
var plugins = require('../plugins');
|
|
|
|
var utils = require('../utils');
|
|
|
|
var utils = require('../utils');
|
|
|
|
|
|
|
|
|
|
|
@ -134,7 +135,7 @@ module.exports = function (User) {
|
|
|
|
user.uid = 0;
|
|
|
|
user.uid = 0;
|
|
|
|
user.username = '[[global:guest]]';
|
|
|
|
user.username = '[[global:guest]]';
|
|
|
|
user.userslug = '';
|
|
|
|
user.userslug = '';
|
|
|
|
user.picture = '';
|
|
|
|
user.picture = User.getDefaultAvatar();
|
|
|
|
user['icon:text'] = '?';
|
|
|
|
user['icon:text'] = '?';
|
|
|
|
user['icon:bgColor'] = '#aaa';
|
|
|
|
user['icon:bgColor'] = '#aaa';
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -145,6 +146,9 @@ module.exports = function (User) {
|
|
|
|
} else if (user.uploadedpicture) {
|
|
|
|
} else if (user.uploadedpicture) {
|
|
|
|
user.uploadedpicture = user.uploadedpicture.startsWith('http') ? user.uploadedpicture : nconf.get('relative_path') + user.uploadedpicture;
|
|
|
|
user.uploadedpicture = user.uploadedpicture.startsWith('http') ? user.uploadedpicture : nconf.get('relative_path') + user.uploadedpicture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (meta.config.defaultAvatar && !user.picture) {
|
|
|
|
|
|
|
|
user.picture = User.getDefaultAvatar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (user.hasOwnProperty('status') && parseInt(user.lastonline, 10)) {
|
|
|
|
if (user.hasOwnProperty('status') && parseInt(user.lastonline, 10)) {
|
|
|
|
user.status = User.getStatus(user);
|
|
|
|
user.status = User.getStatus(user);
|
|
|
@ -155,7 +159,7 @@ module.exports = function (User) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// User Icons
|
|
|
|
// User Icons
|
|
|
|
if (user.hasOwnProperty('picture') && user.username && parseInt(user.uid, 10)) {
|
|
|
|
if (user.hasOwnProperty('picture') && user.username && parseInt(user.uid, 10) && !meta.config.defaultAvatar) {
|
|
|
|
user['icon:text'] = (user.username[0] || '').toUpperCase();
|
|
|
|
user['icon:text'] = (user.username[0] || '').toUpperCase();
|
|
|
|
user['icon:bgColor'] = iconBackgrounds[Array.prototype.reduce.call(user.username, function (cur, next) {
|
|
|
|
user['icon:bgColor'] = iconBackgrounds[Array.prototype.reduce.call(user.username, function (cur, next) {
|
|
|
|
return cur + next.charCodeAt();
|
|
|
|
return cur + next.charCodeAt();
|
|
|
@ -174,6 +178,13 @@ module.exports = function (User) {
|
|
|
|
plugins.fireHook('filter:users.get', users, callback);
|
|
|
|
plugins.fireHook('filter:users.get', users, callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
User.getDefaultAvatar = function () {
|
|
|
|
|
|
|
|
if (!meta.config.defaultAvatar) {
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return meta.config.defaultAvatar.startsWith('http') ? meta.config.defaultAvatar : nconf.get('relative_path') + meta.config.defaultAvatar;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
User.setUserField = function (uid, field, value, callback) {
|
|
|
|
User.setUserField = function (uid, field, value, callback) {
|
|
|
|
callback = callback || function () {};
|
|
|
|
callback = callback || function () {};
|
|
|
|
async.waterfall([
|
|
|
|
async.waterfall([
|
|
|
|