From 69d71c2a495d9cce1984ba2ffddf1d98622b01fe Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Tue, 18 Jul 2023 21:41:53 +0200 Subject: feat: Move to user path media Now media also base on user folder to fetch its media. --- pkg/view/media.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'pkg/view/media.go') 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 -- cgit v1.2.3