chore: stabilize chatwoot parity baseline
This commit is contained in:
@@ -13,8 +13,8 @@ import (
|
||||
// AssignableAgentHandler handles endpoints for finding agents assignable to conversations.
|
||||
// Reference: Chatwoot app/controllers/api/v1/accounts/assignable_agents_controller.rb
|
||||
// Two routes:
|
||||
// 1. GET /api/v1/accounts/:account_id/assignable_agents (with inbox_ids[] query param)
|
||||
// 2. GET /api/v1/accounts/:account_id/inboxes/:inbox_id/assignable_agents (single inbox)
|
||||
// 1. GET /api/v1/accounts/:account_id/assignable_agents (with inbox_ids[] query param)
|
||||
// 2. GET /api/v1/accounts/:account_id/inboxes/:inbox_id/assignable_agents (single inbox)
|
||||
type AssignableAgentHandler struct {
|
||||
svc *service.AssignableAgentService
|
||||
}
|
||||
@@ -26,12 +26,18 @@ func NewAssignableAgentHandler(svc *service.AssignableAgentService) *AssignableA
|
||||
|
||||
// List returns agents that can be assigned to conversations in the specified inbox(es).
|
||||
// Supports two modes:
|
||||
// 1. Standalone resource: GET /api/v1/accounts/:account_id/assignable_agents?inbox_ids[]=1&inbox_ids[]=2
|
||||
// (Ref: Chatwoot resources :assignable_agents, only: [:index] — takes inbox_ids[] query param)
|
||||
// 2. Inbox member action: GET /api/v1/accounts/:account_id/inboxes/:inbox_id/assignable_agents
|
||||
// (Ref: Chatwoot get :assignable_agents, on: :member on inboxes)
|
||||
// 1. Standalone resource: GET /api/v1/accounts/:account_id/assignable_agents?inbox_ids[]=1&inbox_ids[]=2
|
||||
// (Ref: Chatwoot resources :assignable_agents, only: [:index] — takes inbox_ids[] query param)
|
||||
// 2. Inbox member action: GET /api/v1/accounts/:account_id/inboxes/:inbox_id/assignable_agents
|
||||
// (Ref: Chatwoot get :assignable_agents, on: :member on inboxes)
|
||||
//
|
||||
// 返回带workload信息的agent列表,按workload升序排序(最少conversations优先)。
|
||||
func (h *AssignableAgentHandler) List(c *gin.Context) {
|
||||
if h.svc == nil {
|
||||
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrInternal, "assignable agent service unavailable")
|
||||
return
|
||||
}
|
||||
|
||||
accountID := getAccountID(c)
|
||||
if accountID == 0 {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrBadRequest, "invalid account_id")
|
||||
@@ -70,9 +76,9 @@ func (h *AssignableAgentHandler) List(c *gin.Context) {
|
||||
|
||||
agents, svcErr := h.svc.GetAssignableAgents(c.Request.Context(), accountID, inboxIDs)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
response.AbortWithStatusError(c, http.StatusUnprocessableEntity, response.ErrInternal, "failed to list assignable agents")
|
||||
return
|
||||
}
|
||||
|
||||
response.OK(c, agents)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user