mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
breaking: remove socket.emit('user.banUsers');
remove socket.emit('user.unbanUsers');
This commit is contained in:
@@ -24,7 +24,6 @@ const SocketUser = module.exports;
|
|||||||
require('./user/profile')(SocketUser);
|
require('./user/profile')(SocketUser);
|
||||||
require('./user/status')(SocketUser);
|
require('./user/status')(SocketUser);
|
||||||
require('./user/picture')(SocketUser);
|
require('./user/picture')(SocketUser);
|
||||||
require('./user/ban')(SocketUser);
|
|
||||||
require('./user/registration')(SocketUser);
|
require('./user/registration')(SocketUser);
|
||||||
|
|
||||||
SocketUser.exists = async function (socket, data) {
|
SocketUser.exists = async function (socket, data) {
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const api = require('../../api');
|
|
||||||
const websockets = require('../index');
|
|
||||||
|
|
||||||
module.exports = function (SocketUser) {
|
|
||||||
SocketUser.banUsers = async function (socket, data) {
|
|
||||||
websockets.warnDeprecated(socket, 'PUT /api/v3/users/:uid/ban');
|
|
||||||
await Promise.all(data.uids.map(async (uid) => {
|
|
||||||
const payload = { ...data };
|
|
||||||
delete payload.uids;
|
|
||||||
payload.uid = uid;
|
|
||||||
await api.users.ban(socket, payload);
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
SocketUser.unbanUsers = async function (socket, uids) {
|
|
||||||
websockets.warnDeprecated(socket, 'DELETE /api/v3/users/:uid/ban');
|
|
||||||
await Promise.all(uids.map(async (uid) => {
|
|
||||||
await api.users.unban(socket, { uid });
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -121,20 +121,15 @@ describe('socket.io', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should ban a user', (done) => {
|
it('should ban a user', async () => {
|
||||||
const socketUser = require('../src/socket.io/user');
|
const apiUser = require('../src/api/users');
|
||||||
socketUser.banUsers({ uid: adminUid }, { uids: [regularUid], reason: 'spammer' }, (err) => {
|
await apiUser.ban({ uid: adminUid }, { uid: regularUid, reason: 'spammer' });
|
||||||
assert.ifError(err);
|
const data = await user.getLatestBanInfo(regularUid);
|
||||||
user.getLatestBanInfo(regularUid, (err, data) => {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert(data.uid);
|
assert(data.uid);
|
||||||
assert(data.timestamp);
|
assert(data.timestamp);
|
||||||
assert(data.hasOwnProperty('banned_until'));
|
assert(data.hasOwnProperty('banned_until'));
|
||||||
assert(data.hasOwnProperty('banned_until_readable'));
|
assert(data.hasOwnProperty('banned_until_readable'));
|
||||||
assert.equal(data.reason, 'spammer');
|
assert.equal(data.reason, 'spammer');
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return ban reason', (done) => {
|
it('should return ban reason', (done) => {
|
||||||
@@ -145,16 +140,11 @@ describe('socket.io', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unban a user', (done) => {
|
it('should unban a user', async () => {
|
||||||
const socketUser = require('../src/socket.io/user');
|
const apiUser = require('../src/api/users');
|
||||||
socketUser.unbanUsers({ uid: adminUid }, [regularUid], (err) => {
|
await apiUser.unban({ uid: adminUid }, { uid: regularUid });
|
||||||
assert.ifError(err);
|
const isBanned = await user.bans.isBanned(regularUid);
|
||||||
user.bans.isBanned(regularUid, (err, isBanned) => {
|
|
||||||
assert.ifError(err);
|
|
||||||
assert(!isBanned);
|
assert(!isBanned);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make user admin', (done) => {
|
it('should make user admin', (done) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user