From 311ab744fe1bf278b18c25892497271988399e9a Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Tue, 4 Jul 2023 18:38:10 +0200 Subject: feat: Add user based files Now files follow user path configuration --- pkg/view/filesystem.go | 11 ++++++----- pkg/view/media.go | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'pkg/view') diff --git a/pkg/view/filesystem.go b/pkg/view/filesystem.go index d598b88..7fd7331 100644 --- a/pkg/view/filesystem.go +++ b/pkg/view/filesystem.go @@ -11,8 +11,8 @@ import ( type ( FileSystemView struct { - controller service.FileSystemController - settings repository.SettingsRepository + fsService service.FileSystemController + settings repository.SettingsRepository } FilePage struct { Page *service.Page @@ -26,15 +26,16 @@ func NewFileSystemView( settingsRepository repository.SettingsRepository, ) *FileSystemView { return &FileSystemView{ - controller: controller, - settings: settingsRepository, + fsService: controller, + settings: settingsRepository, } } func (self *FileSystemView) Index(ctx *fasthttp.RequestCtx) error { pathValue := string(ctx.FormValue("path")) + token := ext.GetTokenFromCtx(ctx) - page, err := self.controller.GetPage(pathValue) + page, err := self.fsService.GetPage(ctx, token.UserID, pathValue) if err != nil { return err } diff --git a/pkg/view/media.go b/pkg/view/media.go index 0b588f4..bea515d 100644 --- a/pkg/view/media.go +++ b/pkg/view/media.go @@ -98,7 +98,9 @@ func (self *MediaView) GetThumbnail(ctx *fasthttp.RequestCtx) error { path, err := self.mediaRepository.GetThumbnailPath(ctx, pathHash) if err != nil { - return self.GetImage(ctx) + ctx.Redirect("/media/image?path_hash="+pathHash, 307) + // nolint: nilerr + return nil } ctx.Request.Header.SetContentType("image/jpeg") -- cgit v1.2.3