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:
@@ -347,12 +347,17 @@ func (s *conversationService) TransferConversation(conversationID, toUserID int6
|
||||
}
|
||||
|
||||
func (s *conversationService) HandoffByAI(conversationID int64, aiAgent models.AIAgent, reason string) error {
|
||||
return s.HandoffByAIWithRequestID(conversationID, aiAgent, reason, "")
|
||||
}
|
||||
|
||||
func (s *conversationService) HandoffByAIWithRequestID(conversationID int64, aiAgent models.AIAgent, reason string, requestID string) error {
|
||||
if conversationID <= 0 {
|
||||
return errorsx.InvalidParam("会话不存在")
|
||||
}
|
||||
_, err := ConversationHumanDispatchService.HandoffByAI(conversationID, aiAgent, reason)
|
||||
_, err := ConversationHumanDispatchService.HandoffByAIWithRequestID(conversationID, aiAgent, reason, requestID)
|
||||
if err != nil {
|
||||
slog.Warn("schedule-aware ai handoff failed",
|
||||
"requestId", requestID,
|
||||
"conversation_id", conversationID,
|
||||
"ai_agent_id", aiAgent.ID,
|
||||
"error", err)
|
||||
@@ -361,12 +366,17 @@ func (s *conversationService) HandoffByAI(conversationID int64, aiAgent models.A
|
||||
}
|
||||
|
||||
func (s *conversationService) TryOffHoursHandoffByAI(conversationID int64, aiAgent models.AIAgent, reason string) (bool, error) {
|
||||
return s.TryOffHoursHandoffByAIWithRequestID(conversationID, aiAgent, reason, "")
|
||||
}
|
||||
|
||||
func (s *conversationService) TryOffHoursHandoffByAIWithRequestID(conversationID int64, aiAgent models.AIAgent, reason string, requestID string) (bool, error) {
|
||||
if conversationID <= 0 {
|
||||
return false, errorsx.InvalidParam("会话不存在")
|
||||
}
|
||||
handled, err := ConversationHumanDispatchService.TryOffHoursHandoffByAI(conversationID, aiAgent, reason)
|
||||
handled, err := ConversationHumanDispatchService.TryOffHoursHandoffByAIWithRequestID(conversationID, aiAgent, reason, requestID)
|
||||
if err != nil {
|
||||
slog.Warn("off-hours ai handoff failed",
|
||||
"requestId", requestID,
|
||||
"conversation_id", conversationID,
|
||||
"ai_agent_id", aiAgent.ID,
|
||||
"error", err)
|
||||
|
||||
Reference in New Issue
Block a user