feat: add WeCom and Feishu IM bot integration

- support webhook and websocket modes for both platforms
- add im_channel_sessions migration for channel-session mapping
- register IM adapters and callback routes
- update config and docker-compose for IM env vars
This commit is contained in:
nullkey
2026-03-15 18:45:53 +08:00
committed by lyingbug
parent 0e8f1b1c81
commit 9fa969fb5c
18 changed files with 2239 additions and 4 deletions
+17
View File
@@ -59,6 +59,7 @@ type RouterParams struct {
CustomAgentHandler *handler.CustomAgentHandler
SkillHandler *handler.SkillHandler
OrganizationHandler *handler.OrganizationHandler
IMHandler *handler.IMHandler
}
// NewRouter 创建新的路由
@@ -103,6 +104,9 @@ func NewRouter(params RouterParams) *gin.Engine {
serveFrontendStatic(r)
}
// IM 回调路由(在认证中间件之前注册,使用各平台自身的签名验证)
RegisterIMRoutes(r, params.IMHandler)
// 认证中间件
r.Use(middleware.Auth(params.TenantService, params.UserService, params.Config))
@@ -576,6 +580,19 @@ func RegisterOrganizationRoutes(r *gin.RouterGroup, orgHandler *handler.Organiza
r.POST("/shared-agents/disabled", orgHandler.SetSharedAgentDisabledByMe)
}
// RegisterIMRoutes registers IM callback routes.
// These are registered BEFORE auth middleware since IM platforms use their own signature verification.
func RegisterIMRoutes(r *gin.Engine, imHandler *handler.IMHandler) {
im := r.Group("/api/v1/im")
{
// WeCom callback (supports both GET for URL verification and POST for message events)
im.GET("/callback/wecom", imHandler.WeComCallback)
im.POST("/callback/wecom", imHandler.WeComCallback)
// Feishu callback (POST for both URL verification challenge and message events)
im.POST("/callback/feishu", imHandler.FeishuCallback)
}
}
// serveFrontendStatic registers a middleware that serves the frontend SPA
// from the ./web directory if it exists. Must be called BEFORE auth middleware
// so static files are served without authentication.