feat(media): pagination

This commit is contained in:
Florian Sylvain committed 2026-10-13 19:54:59 +02:00
1 parent 04dc151ed7
commit 63c1e7076e
65 files changed
+2960 -365

No files matched your search

+11 -6
View File
@@ -26,8 +26,8 @@ const MaxImageSize int64 = 10485760
const (
MinFilenameRunes = 1
MaxFilenameRunes = 100
DefaultListLimit = 24
MaxListLimit = 100
DefaultListPage = 1
DefaultListSize = 25
)
var allowedContentTypes = map[string]bool{
@@ -128,12 +128,12 @@ type ListQuery struct {
Filter Filter
Variants VariantsFilter
Sort Sort
Limit int
Cursor string
Page int
Size int
}
func NewListQuery() ListQuery {
return ListQuery{Filter: FilterAll, Sort: SortNewest, Limit: DefaultListLimit}
return ListQuery{Filter: FilterAll, Sort: SortNewest, Page: DefaultListPage, Size: DefaultListSize}
}
func (q ListQuery) Validate() error {
@@ -152,7 +152,12 @@ func (q ListQuery) Validate() error {
default:
return ErrInvalidQuery
}
if q.Limit < 1 || q.Limit > MaxListLimit {
if q.Page < 1 {
return ErrInvalidQuery
}
switch q.Size {
case 5, 25, 50, 100:
default:
return ErrInvalidQuery
}
if q.Hash != "" && !sha256Pattern.MatchString(q.Hash) {