Skip to content
Snippets Groups Projects
Verified Commit 27a7f3cb authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: remove unused functions

parent 855acaee
No related branches found
No related tags found
No related merge requests found
......@@ -135,23 +135,6 @@ func isRequestReadOnly(c *gin.Context) bool {
return false
}
func authorizeRequestAllShows(c *gin.Context) (bool, *auth.Session) {
s := getAuthSession(c.Request)
if s.Privileged {
return true, s
}
if s.ReadOnly && !isRequestReadOnly(c) {
c.JSON(http.StatusForbidden, ErrorResponse{Error: "this session is read-only"})
return false, s
}
if s.AllShows {
return true, s
}
c.JSON(http.StatusForbidden, ErrorResponse{Error: "you are not allowed to access all shows"})
return false, s
}
func authorizeRequestForShow(c *gin.Context, showID uint64) (bool, *auth.Session) {
s := getAuthSession(c.Request)
if s.Privileged {
......@@ -181,47 +164,6 @@ func authorizeRequestForShow(c *gin.Context, showID uint64) (bool, *auth.Session
return false, s
}
func authorizeRequestForPlaylist(c *gin.Context, playlistID uint64, api *API) (bool, *auth.Session) {
s := getAuthSession(c.Request)
if s.Privileged {
return true, s
}
if s.ReadOnly && !isRequestReadOnly(c) {
c.JSON(http.StatusForbidden, ErrorResponse{Error: "this session is read-only"})
return false, s
}
if s.AllShows {
return true, s
}
// query the database to get the showId and check if it’s listed in the session
if showID, err := api.store.GetPlaylistShowID(playlistID); err != nil {
if slices.Contains(s.Shows, showID) {
return true, s
}
}
c.JSON(http.StatusForbidden, ErrorResponse{Error: "you are not allowed to access playlist: " + strconv.FormatUint(playlistID, 10)})
return false, s
}
func authorizeRequest(c *gin.Context, api *API) (bool, *auth.Session) {
// showId is passed as query parameter
if showID, _ := idFromString(c.Query("showId")); showID != 0 {
return authorizeRequestForShow(c, showID)
}
// playlist-id is passed as url parameter
if playlistID, _ := idFromString(c.Param("playlist-id")); playlistID != 0 {
return authorizeRequestForPlaylist(c, playlistID, api)
}
return authorizeRequestAllShows(c)
}
func authorizeRequestPrivilegedOrEntitled(c *gin.Context) (bool, *auth.Session) {
s := getAuthSession(c.Request)
......
......@@ -124,14 +124,6 @@ func (st *Store) UpdateFileMetadata(showID uint64, id uint64, metadata map[strin
return
}
func (st *Store) updateFile(showID uint64, id uint64, values ...interface{}) (file *File, err error) {
file = &File{ID: id}
if err = st.db.Model(&file).Where("show_id = ?", showID).Updates(values).Error; err != nil {
return nil, err
}
return file, nil
}
func (st *Store) updateImportState(showID uint64, id uint64, state ImportState) (file *File, err error) {
file = &File{ID: id}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment