Commit 753fdcd5 authored by Christian Pointner's avatar Christian Pointner
Browse files

api: add global playlist endpoints (WIP)

parent 23e51d59
Pipeline #571 passed with stages
in 5 minutes and 48 seconds
......@@ -104,4 +104,10 @@ func InstallHTTPHandler(r *gin.RouterGroup, st *store.Store, im *importer.Import
playlists.DELETE(":playlist-id", api.DeletePlaylistOfShow)
}
}
playlists := r.Group("playlists")
{
playlists.GET("", api.ListPlaylists)
playlists.GET(":playlist-id", api.ReadPlaylist)
}
}
......@@ -35,7 +35,7 @@ import (
func (api *API) ListFilesOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
offset, limit, ok := getPaginationParameter(c)
......@@ -53,7 +53,7 @@ func (api *API) ListFilesOfShow(c *gin.Context) {
func (api *API) CreateFileForShow(c *gin.Context) {
showID := c.Param("show-id")
authorized, sess := authorizeRequest(c, showID)
authorized, sess := authorizeRequestForShow(c, showID)
if !authorized {
return
}
......@@ -139,7 +139,7 @@ create_file_response:
func (api *API) ReadFileOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -158,7 +158,7 @@ func (api *API) ReadFileOfShow(c *gin.Context) {
func (api *API) PatchFileOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -182,7 +182,7 @@ func (api *API) PatchFileOfShow(c *gin.Context) {
func (api *API) DeleteFileOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -203,7 +203,7 @@ func (api *API) DeleteFileOfShow(c *gin.Context) {
func (api *API) ReadUsageOfFile(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -222,7 +222,7 @@ func (api *API) ReadUsageOfFile(c *gin.Context) {
func (api *API) ReadLogsOfFile(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......
......@@ -32,7 +32,7 @@ import (
func (api *API) ListImportsOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
offset, limit, ok := getPaginationParameter(c)
......@@ -50,7 +50,7 @@ func (api *API) ListImportsOfShow(c *gin.Context) {
func (api *API) ReadImportOfFile(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -88,7 +88,7 @@ func (api *API) ReadImportOfFile(c *gin.Context) {
func (api *API) CancelImportOfFile(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......
......@@ -45,7 +45,7 @@ import (
func (api *API) UploadFileSimple(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -372,7 +372,7 @@ func getFlowJSParameterFromQuery(r *http.Request) (id string, chunk, totalChunks
func (api *API) UploadFileFlowJS(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -437,7 +437,7 @@ func (api *API) UploadFileFlowJS(c *gin.Context) {
func (api *API) TestFileFlowJS(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......
......@@ -34,7 +34,7 @@ import (
func (api *API) ListPlaylistsOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
offset, limit, ok := getPaginationParameter(c)
......@@ -52,7 +52,7 @@ func (api *API) ListPlaylistsOfShow(c *gin.Context) {
func (api *API) CreatePlaylistForShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -71,7 +71,7 @@ func (api *API) CreatePlaylistForShow(c *gin.Context) {
func (api *API) ReadPlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -90,7 +90,7 @@ func (api *API) ReadPlaylistOfShow(c *gin.Context) {
func (api *API) UpdatePlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -113,7 +113,7 @@ func (api *API) UpdatePlaylistOfShow(c *gin.Context) {
func (api *API) DeletePlaylistOfShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
......@@ -128,3 +128,13 @@ func (api *API) DeletePlaylistOfShow(c *gin.Context) {
}
c.JSON(http.StatusNoContent, nil)
}
// global
func (api *API) ListPlaylists(c *gin.Context) {
c.JSON(http.StatusNotImplemented, ErrorResponse{Error: "not implemented"})
}
func (api *API) ReadPlaylist(c *gin.Context) {
c.JSON(http.StatusNotImplemented, ErrorResponse{Error: "not implemented"})
}
......@@ -80,7 +80,7 @@ func (api *API) ListShows(c *gin.Context) {
func (api *API) CreateShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, _ := authorizeRequest(c, showID); !authorized {
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
return
}
srcID := c.Query("clone-from")
......@@ -88,7 +88,7 @@ func (api *API) CreateShow(c *gin.Context) {
var show *store.Show
var err error
if srcID != "" {
if authorized, _ := authorizeRequest(c, srcID); !authorized {
if authorized, _ := authorizeRequestForShow(c, srcID); !authorized {
return
}
show, err = api.store.CloneShow(showID, srcID)
......@@ -105,7 +105,7 @@ func (api *API) CreateShow(c *gin.Context) {
func (api *API) DeleteShow(c *gin.Context) {
showID := c.Param("show-id")
if authorized, s := authorizeRequest(c, showID); !authorized {
if authorized, s := authorizeRequestForShow(c, showID); !authorized {
return
} else if !s.Privileged {
c.JSON(http.StatusForbidden, ErrorResponse{Error: "only privileged users are allowed to delete shows"})
......
......@@ -139,7 +139,7 @@ func isRequestReadOnly(c *gin.Context) bool {
return false
}
func authorizeRequest(c *gin.Context, showID string) (bool, *auth.Session) {
func authorizeRequestForShow(c *gin.Context, showID string) (bool, *auth.Session) {
s := getAuthSession(c.Request)
if s.Privileged {
return true, s
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment