fix(feishu): group pairing uses group-level ID instead of per-user

Changed Lark group pairing to use "group:<chatID>" as sender_id
(matching Telegram pattern) so one approval covers the entire group.
Added approvedGroups in-memory cache to avoid DB queries per message.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
viettranxandClaude Opus 4.6 committed 2026-03-03 12:10:36 +07:00
1 parent 4387f6b1ba
commit 7106a74212
2 files changed
+14 -7

No files matched your search

+13 -7
View File
@@ -66,10 +66,7 @@ func (c *Channel) checkGroupPolicy(senderID, chatID string) bool {
}
return false
case "pairing":
paired := false
if c.pairingService != nil {
paired = c.pairingService.IsPaired(senderID, c.Name())
}
// Allowlist bypass (per-user)
inAllowList := c.HasAllowList() && c.IsAllowed(senderID)
inGroupAllowList := false
for _, allowed := range c.groupAllowList {
@@ -78,12 +75,21 @@ func (c *Channel) checkGroupPolicy(senderID, chatID string) bool {
break
}
}
if paired || inAllowList || inGroupAllowList {
if inAllowList || inGroupAllowList {
return true
}
c.sendPairingReply(senderID, chatID)
// Group-level pairing (one approval per group, matching Telegram pattern)
if _, cached := c.approvedGroups.Load(chatID); cached {
return true
}
groupSenderID := fmt.Sprintf("group:%s", chatID)
if c.pairingService != nil && c.pairingService.IsPaired(groupSenderID, c.Name()) {
c.approvedGroups.Store(chatID, true)
return true
}
c.sendPairingReply(groupSenderID, chatID)
return false
default: // "open"
return true
+1
View File
@@ -39,6 +39,7 @@ type Channel struct {
dedup sync.Map // message_id → struct{}
pairingDebounce sync.Map // senderID → time.Time
reactions sync.Map // chatID → *reactionState
approvedGroups sync.Map // chatID → true (in-memory cache for paired groups)
groupAllowList []string
groupHistory *channels.PendingHistory
historyLimit int