feat: add support for request ID tracking across services
- Implemented request ID handling in various services and handlers to improve traceability of requests. - Added new AuthOptions endpoint to expose WxWork and OIDC configuration options. - Updated message and event logging to include request ID for better debugging. - Enhanced login form to dynamically show available authentication options based on server configuration. - Introduced utility functions for normalizing and ensuring valid request IDs. - Updated tests to verify request ID functionality in message sending and event logging.
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"cs-agent/internal/pkg/config"
|
||||
"cs-agent/internal/pkg/dto/request"
|
||||
"cs-agent/internal/pkg/dto/response"
|
||||
"cs-agent/internal/pkg/httpx"
|
||||
"cs-agent/internal/pkg/httpx/params"
|
||||
"cs-agent/internal/services"
|
||||
@@ -29,6 +30,14 @@ func Login(ctx *gin.Context) {
|
||||
httpx.WriteJSON(ctx, ret)
|
||||
}
|
||||
|
||||
func AuthOptions(ctx *gin.Context) {
|
||||
cfg := config.Current()
|
||||
httpx.WriteJSON(ctx, &response.AuthOptionsResponse{
|
||||
WxWorkEnabled: cfg.WxWork.Enabled,
|
||||
OIDCEnabled: cfg.OIDC.Enabled,
|
||||
})
|
||||
}
|
||||
|
||||
func WxWorkLogin(ctx *gin.Context) {
|
||||
loginURL, err := services.WxWorkLoginService.BuildWxWorkLoginURL(ctx.Query("next"))
|
||||
if err != nil {
|
||||
|
||||
@@ -73,7 +73,7 @@ func MessagePostSend(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
item, err := services.MessageService.SendCustomerMessage(req.ConversationID, req.ClientMsgID, req.MessageType, req.Content, req.Payload, *external)
|
||||
item, err := services.MessageService.SendCustomerMessageWithRequestID(req.ConversationID, req.ClientMsgID, req.MessageType, req.Content, req.Payload, *external, httpx.GetRequestID(ctx))
|
||||
if err != nil {
|
||||
httpx.WriteJSON(ctx, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user