Make song/album/artist endpoints read-only

This commit is contained in:
Deluan 2021-11-02 14:44:50 -04:00
parent aaeaa3c590
commit 12818fb590
4 changed files with 4 additions and 52 deletions

View file

@ -366,23 +366,5 @@ func (r *albumRepository) NewInstance() interface{} {
return &model.Album{}
}
func (r albumRepository) Delete(id string) error {
return r.delete(Eq{"album.id": id})
}
func (r albumRepository) Save(entity interface{}) (string, error) {
album := entity.(*model.Album)
id, err := r.put(album.ID, album)
return id, err
}
func (r albumRepository) Update(id string, entity interface{}, cols ...string) error {
album := entity.(*model.Album)
album.ID = id
_, err := r.put(id, album, cols...)
return err
}
var _ model.AlbumRepository = (*albumRepository)(nil)
var _ model.ResourceRepository = (*albumRepository)(nil)
var _ rest.Persistable = (*albumRepository)(nil)

View file

@ -275,22 +275,5 @@ func (r *artistRepository) NewInstance() interface{} {
return &model.Artist{}
}
func (r artistRepository) Delete(id string) error {
return r.delete(Eq{"artist.id": id})
}
func (r artistRepository) Save(entity interface{}) (string, error) {
artist := entity.(*model.Artist)
err := r.Put(artist)
return artist.ID, err
}
func (r artistRepository) Update(id string, entity interface{}, cols ...string) error {
artist := entity.(*model.Artist)
artist.ID = id
return r.Put(artist)
}
var _ model.ArtistRepository = (*artistRepository)(nil)
var _ model.ResourceRepository = (*artistRepository)(nil)
var _ rest.Persistable = (*artistRepository)(nil)

View file

@ -203,18 +203,5 @@ func (r *mediaFileRepository) NewInstance() interface{} {
return &model.MediaFile{}
}
func (r *mediaFileRepository) Save(entity interface{}) (string, error) {
mf := entity.(*model.MediaFile)
err := r.Put(mf)
return mf.ID, err
}
func (r *mediaFileRepository) Update(id string, entity interface{}, cols ...string) error {
mf := entity.(*model.MediaFile)
mf.ID = id
return r.Put(mf)
}
var _ model.MediaFileRepository = (*mediaFileRepository)(nil)
var _ model.ResourceRepository = (*mediaFileRepository)(nil)
var _ rest.Persistable = (*mediaFileRepository)(nil)

View file

@ -34,10 +34,10 @@ func (n *Router) routes() http.Handler {
r.Use(server.Authenticator(n.ds))
r.Use(server.JWTRefresher)
n.R(r, "/user", model.User{}, true)
n.R(r, "/song", model.MediaFile{}, true)
n.R(r, "/album", model.Album{}, true)
n.R(r, "/artist", model.Artist{}, true)
n.R(r, "/genre", model.Genre{}, true)
n.R(r, "/song", model.MediaFile{}, false)
n.R(r, "/album", model.Album{}, false)
n.R(r, "/artist", model.Artist{}, false)
n.R(r, "/genre", model.Genre{}, false)
n.R(r, "/player", model.Player{}, true)
n.R(r, "/playlist", model.Playlist{}, true)
n.R(r, "/transcoding", model.Transcoding{}, conf.Server.EnableTranscodingConfig)