refactor: closes #12629, allow passing arrays to meta.userOrGroupExists

This commit is contained in:
Barış Soner Uşaklı
2024-06-10 16:59:55 -04:00
parent be86d8efc7
commit bad1564301
3 changed files with 32 additions and 28 deletions

View File

@@ -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);