mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-25 09:47:13 +01:00
fix: add user context to scrobble buffer getParticipants call
Added user context handling to scrobbleBufferRepository.Next method to resolve SQL error 'no such column: library_artist.library_id' when processing scrobble entries in multi-library environments. The artist repository now requires user context for proper library filtering, so we fetch the user and temporarily inject it into the context before calling getParticipants. This ensures background scrobbling operations work correctly with multi-library support.
This commit is contained in:
parent
d344eba896
commit
5b8ef74f05
1 changed files with 14 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
. "github.com/Masterminds/squirrel"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/id"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
"github.com/pocketbase/dbx"
|
||||
)
|
||||
|
||||
|
|
@ -82,7 +83,20 @@ func (r *scrobbleBufferRepository) Next(service string, userId string) (*model.S
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Create context with user information for getParticipants call
|
||||
// This is needed because the artist repository requires user context for multi-library support
|
||||
userRepo := NewUserRepository(r.ctx, r.db)
|
||||
user, err := userRepo.Get(res.ScrobbleEntry.UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Temporarily use user context for getParticipants
|
||||
originalCtx := r.ctx
|
||||
r.ctx = request.WithUser(r.ctx, *user)
|
||||
res.ScrobbleEntry.Participants, err = r.getParticipants(&res.ScrobbleEntry.MediaFile)
|
||||
r.ctx = originalCtx // Restore original context
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue