feat(files): add isSharing api

This commit is contained in:
hexxa 2021-08-17 15:08:44 +08:00 committed by Hexxa
parent 94505ae87b
commit 43f2507428
3 changed files with 18 additions and 0 deletions

View file

@ -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"`
}

View file

@ -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,

View file

@ -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)