fix: propagate TenantID in channel InboundMessage for tenant-scoped MCP resolution (#561)

All channel handlers (Telegram, Discord, Slack, Feishu) bypassed
BaseChannel.HandleMessage() and manually constructed InboundMessage
without setting TenantID. This caused the consumer to fall back to
MasterTenantID, making DB-level MCP server grants invisible on
non-master tenants while config-file MCP servers worked fine.

Closes #560

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
daleandClaude Opus 4.6 authored and GitHub committed 2026-03-30 08:12:00 +07:00
1 parent 4ac9e01288
commit 7b066b7056
5 files changed
+7 -1

No files matched your search

+1
View File
@@ -300,6 +300,7 @@ func (c *Channel) handleMessage(_ *discordgo.Session, m *discordgo.MessageCreate
PeerKind: peerKind,
UserID: senderID,
AgentID: targetAgentID,
TenantID: c.TenantID(),
Metadata: metadata,
})
+1
View File
@@ -291,6 +291,7 @@ func (c *Channel) handleMessageEvent(ctx context.Context, event *MessageEvent) {
UserID: userID,
AgentID: targetAgentID,
HistoryLimit: c.historyLimit,
TenantID: c.TenantID(),
Metadata: metadata,
})
+1
View File
@@ -45,6 +45,7 @@ func (c *Channel) HandleMessage(senderID, chatID, content string, mediaPaths []s
Media: mediaFiles,
PeerKind: peerKind,
UserID: userID,
TenantID: c.TenantID(),
Metadata: metadata,
AgentID: c.AgentID(),
})
+3
View File
@@ -129,6 +129,7 @@ func (c *Channel) handleBotCommand(ctx context.Context, message *telego.Message,
PeerKind: peerKind,
AgentID: c.AgentID(),
UserID: strings.SplitN(senderID, "|", 2)[0],
TenantID: c.TenantID(),
Metadata: map[string]string{
"command": "reset",
"local_key": localKey,
@@ -154,6 +155,7 @@ func (c *Channel) handleBotCommand(ctx context.Context, message *telego.Message,
PeerKind: peerKind,
AgentID: c.AgentID(),
UserID: strings.SplitN(senderID, "|", 2)[0],
TenantID: c.TenantID(),
Metadata: map[string]string{
"command": "stop",
"local_key": localKey,
@@ -177,6 +179,7 @@ func (c *Channel) handleBotCommand(ctx context.Context, message *telego.Message,
PeerKind: peerKind,
AgentID: c.AgentID(),
UserID: strings.SplitN(senderID, "|", 2)[0],
TenantID: c.TenantID(),
Metadata: map[string]string{
"command": "stopall",
"local_key": localKey,
+1 -1
View File
@@ -603,6 +603,7 @@ func (c *Channel) handleMessage(ctx context.Context, update telego.Update) {
AgentID: targetAgentID,
HistoryLimit: c.historyLimit,
ToolAllow: topicCfg.tools,
TenantID: c.TenantID(),
Metadata: metadata,
})
@@ -611,4 +612,3 @@ func (c *Channel) handleMessage(ctx context.Context, update telego.Update) {
c.groupHistory.Clear(localKey)
}
}