diff --git a/server/pkg/api/file_link.go b/server/pkg/api/file_link.go index 0a0686f71a..fa7dc9aaae 100644 --- a/server/pkg/api/file_link.go +++ b/server/pkg/api/file_link.go @@ -27,7 +27,14 @@ func (h *FileHandler) ShareUrl(c *gin.Context) { } func (h *FileHandler) LinkInfo(c *gin.Context) { - + resp, err := h.FileUrlCtrl.Info(c) + if err != nil { + handler.Error(c, stacktrace.Propagate(err, "")) + return + } + c.JSON(http.StatusOK, gin.H{ + "file": resp, + }) } func (h *FileHandler) LinkThumbnail(c *gin.Context) { diff --git a/server/pkg/controller/public/file_link.go b/server/pkg/controller/public/file_link.go index 39f1ba9fe7..dad8e139e9 100644 --- a/server/pkg/controller/public/file_link.go +++ b/server/pkg/controller/public/file_link.go @@ -110,6 +110,11 @@ func (c *FileLinkController) UpdateSharedUrl(ctx *gin.Context, req ente.UpdateFi return c.mapRowToFileUrl(ctx, fileLinkRow), nil } +func (c *FileLinkController) Info(ctx *gin.Context) (*ente.File, error) { + accessContext := auth.MustGetFileLinkAccessContext(ctx) + return c.FileRepo.GetFileAttributes(accessContext.FileID) +} + // VerifyPassword verifies if the user has provided correct pw hash. If yes, it returns a signed jwt token which can be // used by the client to pass in other requests for public collection. // Having a separate endpoint for password validation allows us to easily rate-limit the attempts for brute-force diff --git a/server/pkg/middleware/file_link.go b/server/pkg/middleware/file_link.go index e5dcf48a3d..6430382f2c 100644 --- a/server/pkg/middleware/file_link.go +++ b/server/pkg/middleware/file_link.go @@ -20,7 +20,7 @@ import ( "github.com/sirupsen/logrus" ) -var filePasswordWhiteListedURLs = []string{"/file-link/info", "/file-link/verify-password"} +var filePasswordWhiteListedURLs = []string{"/file-link/pass-info", "/file-link/verify-password"} // FileLinkMiddleware intercepts and authenticates incoming requests type FileLinkMiddleware struct {