Merge branch 'master' into develop

This commit is contained in:
Julian Lam
2017-02-24 12:46:40 -05:00
449 changed files with 9202 additions and 6984 deletions

View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';
var async = require('async');
@@ -22,12 +22,12 @@ Categories.getAll = function (socket, data, callback) {
async.apply(db.getSortedSetRange, 'categories:cid', 0, -1),
async.apply(categories.getCategoriesData),
function (categories, next) {
//Hook changes, there is no req, and res
plugins.fireHook('filter:admin.categories.get', {categories: categories}, next);
// Hook changes, there is no req, and res
plugins.fireHook('filter:admin.categories.get', { categories: categories }, next);
},
function (result, next) {
next(null, categories.getTree(result.categories, 0));
}
},
], function (err, categoriesTree) {
if (err) {
return callback(err);
@@ -103,4 +103,4 @@ Categories.copyPrivilegesFrom = function (socket, data, callback) {
categories.copyPrivilegesFrom(data.fromCid, data.toCid, callback);
};
module.exports = Categories;
module.exports = Categories;

View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';
var async = require('async');
var groups = require('../../groups');
@@ -15,7 +15,7 @@ Groups.create = function (socket, data, callback) {
groups.create({
name: data.name,
description: data.description,
ownerUid: socket.uid
ownerUid: socket.uid,
}, callback);
};
@@ -33,7 +33,7 @@ Groups.join = function (socket, data, callback) {
return next(new Error('[[error:group-already-member]]'));
}
groups.join(data.groupName, data.uid, next);
}
},
], callback);
};
@@ -55,7 +55,7 @@ Groups.leave = function (socket, data, callback) {
return next(new Error('[[error:group-not-member]]'));
}
groups.leave(data.groupName, data.uid, next);
}
},
], callback);
};
@@ -67,4 +67,4 @@ Groups.update = function (socket, data, callback) {
groups.update(data.groupName, data.values, callback);
};
module.exports = Groups;
module.exports = Groups;

View File

@@ -1,10 +1,10 @@
"use strict";
'use strict';
var navigationAdmin = require('../../navigation/admin'),
SocketNavigation = {};
var navigationAdmin = require('../../navigation/admin');
var SocketNavigation = {};
SocketNavigation.save = function (socket, data, callback) {
navigationAdmin.save(data, callback);
};
module.exports = SocketNavigation;
module.exports = SocketNavigation;

View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';
var rewardsAdmin = require('../../rewards/admin');
var SocketRewards = module.exports;

View File

@@ -13,7 +13,7 @@ var stats = {};
var totals = {};
var SocketRooms = {
stats: stats,
totals: totals
totals: totals,
};
@@ -22,7 +22,7 @@ pubsub.on('sync:stats:start', function () {
if (err) {
return winston.error(err);
}
pubsub.publish('sync:stats:end', {stats: stats, id: os.hostname() + ':' + nconf.get('port')});
pubsub.publish('sync:stats:end', { stats: stats, id: os.hostname() + ':' + nconf.get('port') });
});
});
@@ -66,7 +66,7 @@ SocketRooms.getAll = function (socket, data, callback) {
recent: 0,
unread: 0,
topics: 0,
category: 0
category: 0,
};
for (var instance in stats) {
@@ -81,7 +81,7 @@ SocketRooms.getAll = function (socket, data, callback) {
totals.users.category += stats[instance].users.category;
stats[instance].topics.forEach(function (topic) {
totals.topics[topic.tid] = totals.topics[topic.tid] || {count: 0, tid: topic.tid};
totals.topics[topic.tid] = totals.topics[topic.tid] || { count: 0, tid: topic.tid };
totals.topics[topic.tid].count += topic.count;
});
}
@@ -89,7 +89,7 @@ SocketRooms.getAll = function (socket, data, callback) {
var topTenTopics = [];
Object.keys(totals.topics).forEach(function (tid) {
topTenTopics.push({tid: tid, count: totals.topics[tid].count});
topTenTopics.push({ tid: tid, count: totals.topics[tid].count });
});
topTenTopics = topTenTopics.sort(function (a, b) {
@@ -109,11 +109,11 @@ SocketRooms.getAll = function (socket, data, callback) {
topTenTopics.forEach(function (topic, index) {
totals.topics[topic.tid] = {
value: topic.count || 0,
title: validator.escape(String(titles[index].title))
title: validator.escape(String(titles[index].title)),
};
});
next(null, totals);
}
},
], callback);
};
@@ -123,7 +123,7 @@ SocketRooms.getOnlineUserCount = function (io) {
if (io) {
for (var key in io.sockets.adapter.rooms) {
if (io.sockets.adapter.rooms.hasOwnProperty(key) && key.startsWith('uid_')) {
++ count;
count += 1;
}
}
}
@@ -143,9 +143,9 @@ SocketRooms.getLocalStats = function (callback) {
recent: 0,
unread: 0,
topics: 0,
category: 0
category: 0,
},
topics: {}
topics: {},
};
if (io) {
@@ -165,7 +165,7 @@ SocketRooms.getLocalStats = function (callback) {
tid = room.match(/^topic_(\d+)/);
if (tid) {
socketData.users.topics += roomClients[room].length;
topTenTopics.push({tid: tid[1], count: roomClients[room].length});
topTenTopics.push({ tid: tid[1], count: roomClients[room].length });
} else if (room.match(/^category/)) {
socketData.users.category += roomClients[room].length;
}
@@ -183,4 +183,4 @@ SocketRooms.getLocalStats = function (callback) {
};
module.exports = SocketRooms;
module.exports = SocketRooms;

View File

@@ -1,10 +1,10 @@
"use strict";
'use strict';
var social = require('../../social'),
SocketSocial = {};
var social = require('../../social');
var SocketSocial = {};
SocketSocial.savePostSharingNetworks = function (socket, data, callback) {
social.setActivePostSharingNetworks(data, callback);
};
module.exports = SocketSocial;
module.exports = SocketSocial;

View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';
var topics = require('../../topics');

View File

@@ -1,4 +1,4 @@
"use strict";
'use strict';
var async = require('async');
var validator = require('validator');
@@ -13,7 +13,7 @@ var plugins = require('../../plugins');
var User = {};
User.makeAdmins = function (socket, uids, callback) {
if(!Array.isArray(uids)) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}
@@ -22,7 +22,7 @@ User.makeAdmins = function (socket, uids, callback) {
return callback(err);
}
for(var i = 0; i < userData.length; i++) {
for (var i = 0; i < userData.length; i += 1) {
if (userData[i] && parseInt(userData[i].banned, 10) === 1) {
return callback(new Error('[[error:cant-make-banned-users-admin]]'));
}
@@ -35,7 +35,7 @@ User.makeAdmins = function (socket, uids, callback) {
};
User.removeAdmins = function (socket, uids, callback) {
if(!Array.isArray(uids)) {
if (!Array.isArray(uids)) {
return callback(new Error('[[error:invalid-data]]'));
}
@@ -109,7 +109,7 @@ User.sendValidationEmail = function (socket, uids, callback) {
next();
}
}, next);
}
},
], callback);
};
@@ -169,17 +169,17 @@ function deleteUsers(socket, uids, method, callback) {
type: 'user-delete',
uid: socket.uid,
targetUid: uid,
ip: socket.ip
ip: socket.ip,
}, next);
},
function (next) {
plugins.fireHook('action:user.delete', {
callerUid: socket.uid,
uid: uid,
ip: socket.ip
ip: socket.ip,
});
next();
}
},
], next);
}, callback);
}
@@ -188,7 +188,7 @@ User.search = function (socket, data, callback) {
var searchData;
async.waterfall([
function (next) {
user.search({query: data.query, searchBy: data.searchBy, uid: socket.uid}, next);
user.search({ query: data.query, searchBy: data.searchBy, uid: socket.uid }, next);
},
function (_searchData, next) {
searchData = _searchData;
@@ -212,7 +212,7 @@ User.search = function (socket, data, callback) {
}
});
next(null, searchData);
}
},
], callback);
};
@@ -230,10 +230,10 @@ User.acceptRegistration = function (socket, data, callback) {
type: 'registration-approved',
uid: socket.uid,
ip: socket.ip,
targetUid: uid
targetUid: uid,
});
next(null, uid);
}
},
], callback);
};
@@ -250,7 +250,7 @@ User.rejectRegistration = function (socket, data, callback) {
username: data.username,
});
next();
}
},
], callback);
};