mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-04 09:08:33 +02:00
refactor: closes #12629, allow passing arrays to meta.userOrGroupExists
This commit is contained in:
@@ -50,8 +50,12 @@ User.exists = async function (uids) {
|
||||
};
|
||||
|
||||
User.existsBySlug = async function (userslug) {
|
||||
const exists = await User.getUidByUserslug(userslug);
|
||||
return !!exists;
|
||||
if (Array.isArray(userslug)) {
|
||||
const uids = await User.getUidsByUserslugs(userslug);
|
||||
return uids.map(uid => !!uid);
|
||||
}
|
||||
const uid = await User.getUidByUserslug(userslug);
|
||||
return !!uid;
|
||||
};
|
||||
|
||||
User.getUidsFromSet = async function (set, start, stop) {
|
||||
@@ -112,6 +116,10 @@ User.getUidByUserslug = async function (userslug) {
|
||||
return await db.sortedSetScore('userslug:uid', userslug);
|
||||
};
|
||||
|
||||
User.getUidsByUserslugs = async function (userslugs) {
|
||||
return await db.sortedSetScores('userslug:uid', userslugs);
|
||||
};
|
||||
|
||||
User.getUsernamesByUids = async function (uids) {
|
||||
const users = await User.getUsersFields(uids, ['username']);
|
||||
return users.map(user => user.username);
|
||||
|
||||
Reference in New Issue
Block a user