mirror of
https://github.com/agent0ai/agent-zero.git
synced 2026-04-28 03:30:23 +00:00
improve: fix allowed users input, auto-strip + prefix, log ignored messages
This commit is contained in:
parent
938e7b9312
commit
66b0a7d3e0
2 changed files with 9 additions and 4 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue