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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user