fix: web bot detection checks alias name first, then whois fallback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-29 11:19:34 +04:00
parent e0e747e005
commit 76fd8dd81a

View File

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