diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-30 16:42:23 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-30 16:42:23 +0300 |
| commit | fea0840ea65afb2b29abb378bd3c96697e0bbf4b (patch) | |
| tree | 9e18fa9d56ecae1a8c3014434eae9a5da82e3919 /internal/repository | |
| parent | 6662a07a58d8d64792501864893ba543581c4dd8 (diff) | |
task ia: fix media listing/filtering semantics (favorites bool, filesize filters, permission scoping)
Diffstat (limited to 'internal/repository')
| -rw-r--r-- | internal/repository/media.go | 4 | ||||
| -rw-r--r-- | internal/repository/repository.go | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/internal/repository/media.go b/internal/repository/media.go index 6c5297b..42b7f03 100644 --- a/internal/repository/media.go +++ b/internal/repository/media.go @@ -134,9 +134,9 @@ func (s *SQLite) ListMedia(ctx context.Context, filter MediaFilter) ([]model.Med like := "%" + term + "%" args = append(args, like, like) } - if filter.Favorites != nil { + if filter.Favorites { joins += ` INNER JOIN favorites f ON f.media_id = media.id AND f.user_id = ?` - args = append(args, *filter.Favorites) + args = append(args, filter.UserID) } if len(filter.Tags) > 0 { joins += ` INNER JOIN media_tags mt ON mt.media_id = media.id INNER JOIN tags t ON t.id = mt.tag_id` diff --git a/internal/repository/repository.go b/internal/repository/repository.go index 227fe79..15da984 100644 --- a/internal/repository/repository.go +++ b/internal/repository/repository.go @@ -97,9 +97,12 @@ type MediaFilter struct { Type *model.MediaType Search string Tags []string - Favorites *int64 // userID if set + Favorites bool // restrict to current user's favorites + UserID int64 MinDuration *float64 MaxDuration *float64 + MinFileSize *int64 + MaxFileSize *int64 Sort string // name, date, duration, play_count, random Limit int Offset int |
