mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
fix(telegram): match DM allowFrom against sender user id
Telegram DM access-control incorrectly used chatId as the allowFrom match key. For DMs, allowFrom entries are typically Telegram user ids (msg.from.id) and/or @usernames. Using chatId causes legitimate DMs to be rejected or silently dropped even when dmPolicy is open/allowlist. This change matches allowFrom against the sender's user id when available, falling back to chatId only if msg.from.id is missing. Tests: existing telegram DM/thread routing tests pass. Closes #4515
This commit is contained in:
@@ -229,8 +229,9 @@ export const buildTelegramMessageContext = async ({
|
||||
}
|
||||
|
||||
if (dmPolicy !== "open") {
|
||||
const candidate = String(chatId);
|
||||
const senderUsername = msg.from?.username ?? "";
|
||||
const senderUserId = msg.from?.id != null ? String(msg.from.id) : null;
|
||||
const candidate = senderUserId ?? String(chatId);
|
||||
const allowMatch = resolveSenderAllowMatch({
|
||||
allow: effectiveDmAllow,
|
||||
senderId: candidate,
|
||||
|
||||
Reference in New Issue
Block a user