feat(conversations): finish message mutation parity
This commit is contained in:
@@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -575,9 +576,10 @@ func (h *ConversationHandler) ListMessages(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
p := pagination.Parse(c)
|
||||
|
||||
messages, _, svcErr := h.conversationSvc.ListMessages(c.Request.Context(), conversation.ID, p.Offset, p.PerPage)
|
||||
after, _ := strconv.ParseUint(c.Query("after"), 10, 64)
|
||||
before, _ := strconv.ParseUint(c.Query("before"), 10, 64)
|
||||
filterInternal := c.Query("filter_internal_messages") != ""
|
||||
messages, _, svcErr := h.messageSvc.ListByConversationFinder(c.Request.Context(), conversation.ID, uint(after), uint(before), filterInternal)
|
||||
if svcErr != nil {
|
||||
handleServiceError(c, svcErr)
|
||||
return
|
||||
@@ -857,6 +859,10 @@ func (h *ConversationHandler) AssignTeam(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, serializeUserFromDB(c.Request.Context(), h.conversationSvc.DB(), *req.AgentID, accountID))
|
||||
return
|
||||
}
|
||||
if req.TeamID != nil {
|
||||
c.JSON(http.StatusOK, serializeTeamFromDB(c.Request.Context(), h.conversationSvc.DB(), *req.TeamID, accountID))
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, serializeConversation(c.Request.Context(), h.conversationSvc.DB(), conversation))
|
||||
}
|
||||
|
||||
@@ -876,6 +882,10 @@ func handleServiceError(c *gin.Context, err error) {
|
||||
response.AbortWithStatusError(c, http.StatusBadRequest, response.ErrValidation, errMsg)
|
||||
return
|
||||
}
|
||||
if strings.Contains(lower, "only allowed") || strings.Contains(lower, "forbidden") {
|
||||
response.AbortWithStatusError(c, http.StatusForbidden, response.ErrForbidden, errMsg)
|
||||
return
|
||||
}
|
||||
response.AbortWithStatusError(c, http.StatusInternalServerError, response.ErrInternal, errMsg)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user