improve: fix allowed users input, auto-strip + prefix, log ignored messages

This commit is contained in:
linuztx 2026-03-27 11:05:58 +08:00
parent 938e7b9312
commit 66b0a7d3e0
2 changed files with 9 additions and 4 deletions

View file

@ -29,7 +29,9 @@
return (config?.allowed_users || []).join(', ');
},
set_allowed(val) {
config.allowed_users = val.split(',').map(s => s.trim()).filter(s => s);
config.allowed_users = val.split(',')
.map(s => s.trim().replace(/^\+/, '').replace(/^0+/, ''))
.filter(s => s);
},
async test_connection() {
this.testing = true;
@ -238,10 +240,10 @@
<div class="field">
<div class="field-label">
<div class="field-title">Allowed Users</div>
<div class="field-description">International format without + or leading 0<br>e.g. 14155551234 for US +1. Empty = allow all</div>
<div class="field-description">Use international format without + or leading 0<br>e.g. +1 (415) 555-1234 → 14155551234. Empty = allow all</div>
</div>
<div class="field-control">
<input type="text" :value="allowed_text()" @input="set_allowed($event.target.value)" placeholder="14155551234, 447911123456" />
<input type="text" :value="allowed_text()" @change="set_allowed($event.target.value)" placeholder="14155551234, 447911123456" />
</div>
</div>

View file

@ -200,7 +200,10 @@ async function startSocket() {
// Check allowlist (resolve LID -> phone if needed)
if (!msg.key.fromMe && ALLOWED_USERS.length > 0) {
const resolvedNumber = lidToPhone[senderNumber] || senderNumber;
if (!ALLOWED_USERS.includes(resolvedNumber)) continue;
if (!ALLOWED_USERS.includes(resolvedNumber)) {
console.log(`[bridge] Ignored message from ${resolvedNumber} (not in allowed users)`);
continue;
}
}
// Unwrap documentWithCaptionMessage (Baileys wraps captioned docs)