aboutsummaryrefslogtreecommitdiff
path: root/pkg/view
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/view')
-rw-r--r--pkg/view/media.go15
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