From 76fd8dd81a395f19f89742679ade59d2aab8b2fc Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Sun, 29 Mar 2026 11:19:34 +0400 Subject: [PATCH] fix: web bot detection checks alias name first, then whois fallback Co-Authored-By: Claude Opus 4.6 (1M context) --- .../crates/warzone-server/src/routes/web.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/warzone/crates/warzone-server/src/routes/web.rs b/warzone/crates/warzone-server/src/routes/web.rs index ca42e43..35695a2 100644 --- a/warzone/crates/warzone-server/src/routes/web.rs +++ b/warzone/crates/warzone-server/src/routes/web.rs @@ -1207,11 +1207,20 @@ async function doSend() { // Check if peer is a bot — send plaintext instead of E2E let isBotPeer = false; - try { - const wr = await fetch(SERVER + '/v1/alias/whois/' + normFP(peer)); - const wd = await wr.json(); - if (wd.alias && (wd.alias.endsWith('bot') || wd.alias.endsWith('Bot') || wd.alias.endsWith('_bot') || wd.alias === 'botfather')) isBotPeer = true; - } catch(e) {} + const peerRaw = $peerInput.value.trim(); + // Check by alias name if peer was set via @alias + if (peerRaw.startsWith('@')) { + const aname = peerRaw.slice(1).toLowerCase(); + isBotPeer = aname.endsWith('bot') || aname.endsWith('_bot') || aname === 'botfather'; + } + // Also check by fingerprint reverse-lookup + if (!isBotPeer) { + try { + const wr = await fetch(SERVER + '/v1/alias/whois/' + peer); + const wd = await wr.json(); + if (wd.alias && (wd.alias.endsWith('bot') || wd.alias.endsWith('Bot') || wd.alias.endsWith('_bot') || wd.alias === 'botfather')) isBotPeer = true; + } catch(e) {} + } if (isBotPeer) { const msgId = crypto.randomUUID ? crypto.randomUUID() : Date.now().toString();