feat(inboxes): enforce chatwoot inbox limits

This commit is contained in:
2026-06-05 11:35:38 +08:00
parent ec94fb1ab2
commit 4ddfaed845
20 changed files with 425 additions and 138 deletions
+11
View File
@@ -134,6 +134,9 @@ func (h *InboxHandler) Create(c *gin.Context) {
inbox, svcErr := h.svc.Create(c.Request.Context(), accountID, req)
if svcErr != nil {
if renderInboxLimitExceeded(c, svcErr) {
return
}
c.JSON(http.StatusUnprocessableEntity, gin.H{"error": "failed to create inbox"})
return
}
@@ -239,6 +242,14 @@ func (h *InboxHandler) Delete(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Your inbox deletion request will be processed in some time."})
}
func renderInboxLimitExceeded(c *gin.Context, err error) bool {
if !service.IsInboxLimitExceeded(err) {
return false
}
c.JSON(http.StatusPaymentRequired, gin.H{"error": service.InboxLimitExceededMessage})
return true
}
func bindCreateInboxRequest(c *gin.Context, req *service.CreateInboxRequest) error {
if strings.Contains(c.ContentType(), "json") {
return bindCreateInboxJSON(c, req)