separate telegram private and group allowlist checks

This commit is contained in:
DBT
2026-02-25 07:30:38 +00:00
parent fe1285b690
commit 74aa7d80bc

View File

@@ -334,7 +334,11 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
return nil
}
func (c *TelegramChannel) isAllowedChat(chatID int64) bool {
func (c *TelegramChannel) isAllowedChat(chatID int64, chatType string) bool {
// Private chats are governed by allow_from (sender allowlist), not allow_chats.
if strings.TrimSpace(chatType) == telego.ChatTypePrivate {
return true
}
if len(c.config.AllowChats) == 0 {
return true
}
@@ -458,7 +462,7 @@ func (c *TelegramChannel) handleMessage(runCtx context.Context, message *telego.
content = "[empty message]"
}
if !c.isAllowedChat(chatID) {
if !c.isAllowedChat(chatID, message.Chat.Type) {
logger.WarnCF("telegram", "Telegram message rejected by chat allowlist", map[string]interface{}{
logger.FieldSenderID: senderID,
logger.FieldChatID: chatID,