mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 12:36:02 +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/status')(SocketUser);
|
||||
require('./user/picture')(SocketUser);
|
||||
require('./user/ban')(SocketUser);
|
||||
require('./user/registration')(SocketUser);
|
||||
|
||||
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) => {
|
||||
const socketUser = require('../src/socket.io/user');
|
||||
socketUser.banUsers({ uid: adminUid }, { uids: [regularUid], reason: 'spammer' }, (err) => {
|
||||
assert.ifError(err);
|
||||
user.getLatestBanInfo(regularUid, (err, data) => {
|
||||
assert.ifError(err);
|
||||
it('should ban a user', async () => {
|
||||
const apiUser = require('../src/api/users');
|
||||
await apiUser.ban({ uid: adminUid }, { uid: regularUid, reason: 'spammer' });
|
||||
const data = await user.getLatestBanInfo(regularUid);
|
||||
assert(data.uid);
|
||||
assert(data.timestamp);
|
||||
assert(data.hasOwnProperty('banned_until'));
|
||||
assert(data.hasOwnProperty('banned_until_readable'));
|
||||
assert.equal(data.reason, 'spammer');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should return ban reason', (done) => {
|
||||
@@ -145,16 +140,11 @@ describe('socket.io', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should unban a user', (done) => {
|
||||
const socketUser = require('../src/socket.io/user');
|
||||
socketUser.unbanUsers({ uid: adminUid }, [regularUid], (err) => {
|
||||
assert.ifError(err);
|
||||
user.bans.isBanned(regularUid, (err, isBanned) => {
|
||||
assert.ifError(err);
|
||||
it('should unban a user', async () => {
|
||||
const apiUser = require('../src/api/users');
|
||||
await apiUser.unban({ uid: adminUid }, { uid: regularUid });
|
||||
const isBanned = await user.bans.isBanned(regularUid);
|
||||
assert(!isBanned);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should make user admin', (done) => {
|
||||
|
||||
Reference in New Issue
Block a user