Files
warmbly/internal/app/unibox/thread.go
T
Matthew Meszaros 7b5a87d1d1 feat: add unibox scheduled send backend
Add Unibox overview, snooze, and scheduled-send endpoints with task repository support, queue caps, execution-time guards, and snooze persistence.
2026-05-31 04:26:26 +00:00

41 lines
1008 B
Go

package unibox
import (
"context"
"strconv"
"github.com/getsentry/sentry-go"
"github.com/google/uuid"
"github.com/warmbly/warmbly/internal/errx"
"github.com/warmbly/warmbly/internal/models"
)
// GetByThread returns every message in a thread. limit/cursor are
// optional — clients that want the whole conversation can leave them
// empty and the service returns up to ThreadLimitMax messages.
func (s *uniboxService) GetByThread(
ctx context.Context,
userID, emailID uuid.UUID,
threadID, limit, cursor string,
) (*models.MailSearchResult, *errx.Error) {
l := DefaultThreadLimit
if limit != "" {
parsed, err := strconv.Atoi(limit)
if err != nil {
return nil, errx.ErrUniboxLimit
}
if parsed < LimitMin || parsed > ThreadLimitMax {
return nil, errx.ErrUniboxLimit
}
l = parsed
}
resp, err := s.uniboxRepository.GetByThread(ctx, userID, emailID, threadID, l, cursor)
if err != nil {
sentry.CaptureException(err)
return nil, errx.InternalError()
}
return resp, nil
}