diff options
author | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-18 21:41:53 +0200 |
---|---|---|
committer | Gabriel Arakaki Giovanini <mail@gabrielgio.me> | 2023-07-18 21:41:53 +0200 |
commit | 69d71c2a495d9cce1984ba2ffddf1d98622b01fe (patch) | |
tree | 3abd105a970fe773c0b19cb0c4f974688001e5e0 /pkg/view | |
parent | 05a8dbf46792adfef007a0ffbcb654026db036fa (diff) | |
download | lens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.tar.gz lens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.tar.bz2 lens-69d71c2a495d9cce1984ba2ffddf1d98622b01fe.zip |
feat: Move to user path media
Now media also base on user folder to fetch its media.
Diffstat (limited to 'pkg/view')
-rw-r--r-- | pkg/view/media.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/pkg/view/media.go b/pkg/view/media.go index bea515d..6d380e2 100644 --- a/pkg/view/media.go +++ b/pkg/view/media.go @@ -13,6 +13,7 @@ import ( type ( MediaView struct { mediaRepository repository.MediaRepository + userRepository repository.UserRepository } Page struct { @@ -51,14 +52,26 @@ func getPagination(ctx *fasthttp.RequestCtx) *repository.Pagination { } } -func NewMediaView(mediaRepository repository.MediaRepository) *MediaView { +func NewMediaView( + mediaRepository repository.MediaRepository, + userRepository repository.UserRepository, +) *MediaView { return &MediaView{ mediaRepository: mediaRepository, + userRepository: userRepository, } } func (self *MediaView) Index(ctx *fasthttp.RequestCtx) error { p := getPagination(ctx) + token := ext.GetTokenFromCtx(ctx) + + userPath, err := self.userRepository.GetPathFromUserID(ctx, token.UserID) + if err != nil { + return err + } + + p.Path = userPath medias, err := self.mediaRepository.List(ctx, p) if err != nil { return err |