feat(files): add isSharing api
This commit is contained in:
parent
94505ae87b
commit
43f2507428
3 changed files with 18 additions and 0 deletions
|
@ -785,6 +785,21 @@ func (h *FileHandlers) DelSharing(c *gin.Context) {
|
||||||
c.JSON(q.Resp(200))
|
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 {
|
type SharingResp struct {
|
||||||
SharingDirs []string `json:"sharingPaths"`
|
SharingDirs []string `json:"sharingPaths"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, "POST", "/v1/fs/sharings"): true,
|
||||||
apiRuleCname(userstore.AdminRole, "DELETE", "/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"): true,
|
||||||
|
apiRuleCname(userstore.AdminRole, "GET", "/v1/fs/sharings/exist"): true,
|
||||||
// user rules
|
// user rules
|
||||||
apiRuleCname(userstore.UserRole, "GET", "/"): true,
|
apiRuleCname(userstore.UserRole, "GET", "/"): true,
|
||||||
apiRuleCname(userstore.UserRole, "GET", publicPath): 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, "POST", "/v1/fs/sharings"): true,
|
||||||
apiRuleCname(userstore.UserRole, "DELETE", "/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"): true,
|
||||||
|
apiRuleCname(userstore.UserRole, "GET", "/v1/fs/sharings/exist"): true,
|
||||||
// visitor rules
|
// visitor rules
|
||||||
apiRuleCname(userstore.VisitorRole, "GET", "/"): true,
|
apiRuleCname(userstore.VisitorRole, "GET", "/"): true,
|
||||||
apiRuleCname(userstore.VisitorRole, "GET", publicPath): true,
|
apiRuleCname(userstore.VisitorRole, "GET", publicPath): true,
|
||||||
|
|
|
@ -225,6 +225,7 @@ func initHandlers(router *gin.Engine, cfg gocfg.ICfg, deps *depidx.Deps) (*gin.E
|
||||||
filesAPI.POST("/sharings", fileHdrs.AddSharing)
|
filesAPI.POST("/sharings", fileHdrs.AddSharing)
|
||||||
filesAPI.DELETE("/sharings", fileHdrs.DelSharing)
|
filesAPI.DELETE("/sharings", fileHdrs.DelSharing)
|
||||||
filesAPI.GET("/sharings", fileHdrs.ListSharings)
|
filesAPI.GET("/sharings", fileHdrs.ListSharings)
|
||||||
|
filesAPI.GET("/sharings/exist", fileHdrs.IsSharing)
|
||||||
|
|
||||||
filesAPI.GET("/metadata", fileHdrs.Metadata)
|
filesAPI.GET("/metadata", fileHdrs.Metadata)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue