feat: update unban logic/invocation and refactor User.bans module

* auto unban when User.getUsersFields is called and the user is banned but has expired

* cleanups and removal of expiry_readable

* expiry_readable make an alias for backward compatibility

* User.bans.func vs User.*ban*Func

* console.log cleanups, plus todo message added

* use code util.deprecate

* fix: remove ununsed winston require
This commit is contained in:
Aziz Khoury
2019-04-05 21:14:49 +03:00
committed by Julian Lam
parent ed91d3f2c8
commit 3fbb6faf28
11 changed files with 115 additions and 68 deletions

View File

@@ -132,8 +132,8 @@ describe('socket.io', function () {
assert.ifError(err);
assert(data.uid);
assert(data.timestamp);
assert(data.hasOwnProperty('expiry'));
assert(data.hasOwnProperty('expiry_readable'));
assert(data.hasOwnProperty('banned_until'));
assert(data.hasOwnProperty('banned_until_readable'));
assert.equal(data.reason, 'spammer');
done();
});
@@ -141,7 +141,7 @@ describe('socket.io', function () {
});
it('should return ban reason', function (done) {
user.getBannedReason(regularUid, function (err, reason) {
user.bans.getReason(regularUid, function (err, reason) {
assert.ifError(err);
assert.equal(reason, 'spammer');
done();
@@ -152,7 +152,7 @@ describe('socket.io', function () {
var socketUser = require('../src/socket.io/user');
socketUser.unbanUsers({ uid: adminUid }, [regularUid], function (err) {
assert.ifError(err);
user.isBanned(regularUid, function (err, isBanned) {
user.bans.isBanned(regularUid, function (err, isBanned) {
assert.ifError(err);
assert(!isBanned);
done();