Usersearch: Exclude global banned users

This commit is contained in:
Kris Johnson 2021-09-13 21:47:49 -06:00
parent e08e1a9cf0
commit ff13a8d8a3
2 changed files with 8 additions and 0 deletions

View File

@ -22,6 +22,7 @@ function searchUsernames(target: string, page = false) {
};
for (const curUser of Users.users.values()) {
if (!curUser.id.includes(target) || curUser.id.startsWith('guest')) continue;
if (Punishments.isGlobalBanned(curUser)) continue;
if (curUser.connected) {
results.online.push(`${!page ? ONLINE_SYMBOL : ''} ${curUser.name}`);
} else {

View File

@ -1800,6 +1800,13 @@ export const Punishments = new class {
if (room.parent) return Punishments.isRoomBanned(user, room.parent.roomid);
}
isGlobalBanned(user: User): Punishment | undefined {
if (!user) throw new Error(`Trying to check if a non-existent user is global banned.`);
let punishment = Punishments.userids.getByType(user.id, "BAN") || Punishments.userids.getByType(user.id, "FORCEBAN");
if (punishment) return punishment;
}
isBlacklistedSharedIp(ip: string) {
const num = IPTools.ipToNumber(ip);
if (!num) throw new Error(`Invalid IP address: '${ip}'`);