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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user