From ff13a8d8a369bdc876f374fa1a9d4e6089b14c00 Mon Sep 17 00:00:00 2001 From: Kris Johnson <11083252+KrisXV@users.noreply.github.com> Date: Mon, 13 Sep 2021 21:47:49 -0600 Subject: [PATCH] Usersearch: Exclude global banned users --- server/chat-plugins/usersearch.ts | 1 + server/punishments.ts | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/server/chat-plugins/usersearch.ts b/server/chat-plugins/usersearch.ts index ba9a545eec..212c9c184d 100644 --- a/server/chat-plugins/usersearch.ts +++ b/server/chat-plugins/usersearch.ts @@ -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 { diff --git a/server/punishments.ts b/server/punishments.ts index d9e4945683..dadcd28589 100644 --- a/server/punishments.ts +++ b/server/punishments.ts @@ -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}'`);