feat(attachments): align list pagination

This commit is contained in:
2026-06-06 02:19:10 +08:00
parent 0fb4e6c500
commit 3c30596bad
6 changed files with 97 additions and 9 deletions
@@ -24,6 +24,8 @@ type ConversationHandler struct {
auditSvc *service.AuditService
}
const chatwootAttachmentResultsPerPage = 100
// NewConversationHandler creates a new ConversationHandler.
func NewConversationHandler(conversationSvc *service.ConversationService, messageSvc *service.MessageService) *ConversationHandler {
return &ConversationHandler{conversationSvc: conversationSvc, messageSvc: messageSvc}
@@ -763,12 +765,12 @@ func (h *ConversationHandler) ListAttachments(c *gin.Context) {
return
}
p := pagination.Parse(c)
_, offset := fixedPageOffset(c, chatwootAttachmentResultsPerPage)
conversation, ok := h.resolveConversationRoute(c, accountID, conversationID)
if !ok {
return
}
attachments, total, svcErr := h.messageSvc.ListAttachments(c.Request.Context(), accountID, conversation.ID, p.Offset, p.PerPage)
attachments, total, svcErr := h.messageSvc.ListAttachments(c.Request.Context(), accountID, conversation.ID, offset, chatwootAttachmentResultsPerPage)
if svcErr != nil {
handleServiceError(c, svcErr)
return