feat(conversations): complete manual AI takeover
This commit is contained in:
@@ -1059,9 +1059,10 @@ func (h *ConversationHandler) AssignTeam(c *gin.Context) {
|
||||
}
|
||||
|
||||
var req struct {
|
||||
AgentID *uint `json:"agent_id"`
|
||||
AssigneeID *uint `json:"assignee_id"`
|
||||
TeamID *uint `json:"team_id"`
|
||||
AgentID *uint `json:"agent_id"`
|
||||
AssigneeID *uint `json:"assignee_id"`
|
||||
AssigneeType string `json:"assignee_type"`
|
||||
TeamID *uint `json:"team_id"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrValidation, err.Error())
|
||||
@@ -1076,6 +1077,23 @@ func (h *ConversationHandler) AssignTeam(c *gin.Context) {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if req.AssigneeType == "AgentBot" {
|
||||
if agentID == nil {
|
||||
agentID = new(uint)
|
||||
}
|
||||
conversation, bot, svcErr := h.conversationSvc.AssignAgentBot(c.Request.Context(), accountID, conversation.ID, *agentID)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
}
|
||||
recordAuditMutation(c, h.auditSvc, auditMutation{AccountID: accountID, AuditableType: "Conversation", AuditableID: conversation.ID, Action: "update", AuditedChanges: gin.H{"assignee_agent_bot_id": conversation.AssigneeAgentBotID}})
|
||||
if bot == nil {
|
||||
c.JSON(http.StatusOK, nil)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, serializeAgentBotSlim(bot))
|
||||
return
|
||||
}
|
||||
conversation, svcErr := h.conversationSvc.AssignTeam(c.Request.Context(), accountID, conversation.ID, agentID, req.TeamID)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
|
||||
Reference in New Issue
Block a user