Skip to content

Commit

Permalink
refactor: remove unused search call
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Oct 14, 2020
1 parent 2d6ea6e commit dd7424e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
1 change: 0 additions & 1 deletion src/privileges/admin.js
Expand Up @@ -79,7 +79,6 @@ module.exports = function (privileges) {
'admin.user.deleteUsers': 'admin:users',
'admin.user.deleteUsersAndContent': 'admin:users',
'admin.user.createUser': 'admin:users',
'admin.user.search': 'admin:users',
'admin.user.invite': 'admin:users',

'admin.getSearchDict': 'admin:settings',
Expand Down
26 changes: 0 additions & 26 deletions src/socket.io/admin/user.js
Expand Up @@ -186,32 +186,6 @@ async function deleteUsers(socket, uids, method) {
}
}

User.search = async function (socket, data) {
// TODO: deprecate
const searchData = await user.search({
query: data.query,
searchBy: data.searchBy,
uid: socket.uid,
});

if (!searchData.users.length) {
return searchData;
}

const uids = searchData.users.map(user => user && user.uid);
const userInfo = await user.getUsersFields(uids, ['email', 'flags', 'lastonline', 'joindate']);

searchData.users.forEach(function (user, index) {
if (user && userInfo[index]) {
user.email = userInfo[index].email;
user.flags = userInfo[index].flags || 0;
user.lastonlineISO = userInfo[index].lastonlineISO;
user.joindateISO = userInfo[index].joindateISO;
}
});
return searchData;
};

User.restartJobs = async function () {
user.startJobs();
};
Expand Down
9 changes: 0 additions & 9 deletions test/socket.io.js
Expand Up @@ -277,15 +277,6 @@ describe('socket.io', function () {
});
});

it('should search users', function (done) {
socketAdmin.user.search({ uid: adminUid }, { query: 'reg', searchBy: 'username' }, function (err, data) {
assert.ifError(err);
assert.equal(data.matchCount, 1);
assert.equal(data.users[0].username, 'regular');
done();
});
});

it('should push unread notifications on reconnect', function (done) {
var socketMeta = require('../src/socket.io/meta');
socketMeta.reconnected({ uid: 1 }, {}, function (err) {
Expand Down

0 comments on commit dd7424e

Please sign in to comment.