mirror of
https://github.com/navidrome/navidrome.git
synced 2026-07-31 09:16:30 -04:00
Like Subsonic's setStar/setRating, the Jellyfin favorite and rating endpoints now broadcast a refreshResource event, so the web UI updates immediately when a Jellyfin client changes an annotation. Also fixes model.GetEntityByID to propagate unexpected repository errors instead of reporting them as not-found, preserving the 500-vs-404 distinction for all its callers.
28 lines
688 B
Go
28 lines
688 B
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
// TODO: Should the type be encoded in the ID?
|
|
func GetEntityByID(ctx context.Context, ds DataStore, id string) (any, error) {
|
|
getters := []func() (any, error){
|
|
func() (any, error) { return ds.Artist(ctx).Get(id) },
|
|
func() (any, error) { return ds.Album(ctx).Get(id) },
|
|
func() (any, error) { return ds.Playlist(ctx).Get(id) },
|
|
func() (any, error) { return ds.MediaFile(ctx).Get(id) },
|
|
func() (any, error) { return ds.Radio(ctx).Get(id) },
|
|
}
|
|
for _, get := range getters {
|
|
entity, err := get()
|
|
if err == nil {
|
|
return entity, nil
|
|
}
|
|
if !errors.Is(err, ErrNotFound) {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nil, ErrNotFound
|
|
}
|