diff --git a/src/handlers/fileshdr/handlers.go b/src/handlers/fileshdr/handlers.go index 820d1e3..f20e158 100644 --- a/src/handlers/fileshdr/handlers.go +++ b/src/handlers/fileshdr/handlers.go @@ -785,6 +785,21 @@ func (h *FileHandlers) DelSharing(c *gin.Context) { c.JSON(q.Resp(200)) } +func (h *FileHandlers) IsSharing(c *gin.Context) { + req := &SharingReq{} + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(q.ErrResp(c, 400, err)) + return + } + + _, ok := h.deps.FileInfos().GetSharing(req.SharingPath) + if ok { + c.JSON(q.Resp(200)) + } else { + c.JSON(q.Resp(404)) + } +} + type SharingResp struct { SharingDirs []string `json:"sharingPaths"` } diff --git a/src/handlers/multiusers/handlers.go b/src/handlers/multiusers/handlers.go index 16b3981..ce994b7 100644 --- a/src/handlers/multiusers/handlers.go +++ b/src/handlers/multiusers/handlers.go @@ -67,6 +67,7 @@ func NewMultiUsersSvc(cfg gocfg.ICfg, deps *depidx.Deps) (*MultiUsersSvc, error) apiRuleCname(userstore.AdminRole, "POST", "/v1/fs/sharings"): true, apiRuleCname(userstore.AdminRole, "DELETE", "/v1/fs/sharings"): true, apiRuleCname(userstore.AdminRole, "GET", "/v1/fs/sharings"): true, + apiRuleCname(userstore.AdminRole, "GET", "/v1/fs/sharings/exist"): true, // user rules apiRuleCname(userstore.UserRole, "GET", "/"): true, apiRuleCname(userstore.UserRole, "GET", publicPath): true, @@ -93,6 +94,7 @@ func NewMultiUsersSvc(cfg gocfg.ICfg, deps *depidx.Deps) (*MultiUsersSvc, error) apiRuleCname(userstore.UserRole, "POST", "/v1/fs/sharings"): true, apiRuleCname(userstore.UserRole, "DELETE", "/v1/fs/sharings"): true, apiRuleCname(userstore.UserRole, "GET", "/v1/fs/sharings"): true, + apiRuleCname(userstore.UserRole, "GET", "/v1/fs/sharings/exist"): true, // visitor rules apiRuleCname(userstore.VisitorRole, "GET", "/"): true, apiRuleCname(userstore.VisitorRole, "GET", publicPath): true, diff --git a/src/server/server.go b/src/server/server.go index c7b2095..ef3fed2 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -225,6 +225,7 @@ func initHandlers(router *gin.Engine, cfg gocfg.ICfg, deps *depidx.Deps) (*gin.E filesAPI.POST("/sharings", fileHdrs.AddSharing) filesAPI.DELETE("/sharings", fileHdrs.DelSharing) filesAPI.GET("/sharings", fileHdrs.ListSharings) + filesAPI.GET("/sharings/exist", fileHdrs.IsSharing) filesAPI.GET("/metadata", fileHdrs.Metadata)