feat: PlatformChannel 支持 AdapterID/AdapterName — 多账号全链路区分

- PlatformChannel 新增 AdapterID + AdapterName 字段
- AddOrUpdatePlatformChannel 接受 adapter 信息参数
- channel_sync 传递 adapter_id/adapter_name
- 消息处理路径传递 adapter_name

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-23 18:01:27 +08:00
parent 45fac267fe
commit c96bd23f83
6 changed files with 16 additions and 152 deletions
+3 -1
View File
@@ -48,6 +48,8 @@ func doSync(thinker *background.Thinker, client *http.Client, baseURL, token str
ChannelType string `json:"channel_type"`
ChannelID string `json:"channel_id"`
ChannelName string `json:"channel_name,omitempty"`
AdapterID string `json:"adapter_id,omitempty"`
AdapterName string `json:"adapter_name,omitempty"`
} `json:"channels"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
@@ -56,7 +58,7 @@ func doSync(thinker *background.Thinker, client *http.Client, baseURL, token str
}
for _, ch := range result.Channels {
thinker.AddOrUpdatePlatformChannel(ch.Platform, ch.ChannelType, ch.ChannelID, ch.ChannelName)
thinker.AddOrUpdatePlatformChannel(ch.Platform, ch.ChannelType, ch.ChannelID, ch.ChannelName, ch.AdapterID, ch.AdapterName)
}
// Also fetch platforms to get bot UIDs.
+2 -2
View File
@@ -967,7 +967,7 @@ func handleChat(
adapterKey = req.Source.AdapterName
}
thinker.SetBotUID(adapterKey, req.Source.BotUID)
thinker.AddOrUpdatePlatformChannel(req.Source.Platform, req.Source.ChannelType, req.Source.ChannelID, req.Source.GroupName)
thinker.AddOrUpdatePlatformChannel(req.Source.Platform, req.Source.ChannelType, req.Source.ChannelID, req.Source.GroupName, "", req.Source.AdapterName)
}
}
// 图片预处理:静默观察时也分析图片内容,供后台思考使用
@@ -1007,7 +1007,7 @@ func handleChat(
thinker.SetBotUID(adapterKey, req.Source.BotUID)
}
if req.Source.Platform != "" && req.Source.ChannelID != "" {
thinker.AddOrUpdatePlatformChannel(req.Source.Platform, req.Source.ChannelType, req.Source.ChannelID, req.Source.GroupName)
thinker.AddOrUpdatePlatformChannel(req.Source.Platform, req.Source.ChannelType, req.Source.ChannelID, req.Source.GroupName, "", req.Source.AdapterName)
}
}