mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-15 18:15:47 +00:00
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:
1 parent
4387f6b1ba
commit
7106a74212
2 files changed
+14
-7
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user