fix(scrobble): plays that can't be sent no longer block ListenBrainz for everyone (#8103)
The worker skipped a queued play whose account had since switched ListenBrainz off, or whose token couldn't be read, and left it pending. The batch is the oldest fifty pending rows, so skipped rows came back first on every tick, and fifty of them stopped scrobbling for every account. They are now marked failed with the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,9 +85,20 @@ func (w *Worker) tickOnce(ctx context.Context) error {
|
||||
userID pgtype.UUID
|
||||
}
|
||||
batches := map[string]*userBatch{}
|
||||
// A row that can't be sent is marked failed rather than left pending.
|
||||
// The batch is the oldest pending rows, so rows left behind would come
|
||||
// back first on every tick, and a full batch of them would stop
|
||||
// ListenBrainz scrobbling for every account.
|
||||
unsendable := func(id pgtype.UUID, why string) {
|
||||
if err := q.MarkScrobbleFailed(ctx, dbq.MarkScrobbleFailedParams{ID: id, LastError: &why}); err != nil {
|
||||
w.logger.Error("scrobble: MarkScrobbleFailed", "queue_id", id, "err", err)
|
||||
}
|
||||
}
|
||||
for _, r := range rows {
|
||||
if r.LbToken == nil || *r.LbToken == "" || !r.LbEnabled {
|
||||
// Defensive: row got into queue but user since disabled. Skip.
|
||||
// ListenBrainz was switched off, or its token removed, after the
|
||||
// play was queued.
|
||||
unsendable(r.QueueID, "ListenBrainz is off for this account")
|
||||
continue
|
||||
}
|
||||
key := r.UserID.String()
|
||||
@@ -95,6 +106,7 @@ func (w *Worker) tickOnce(ctx context.Context) error {
|
||||
if ub == nil {
|
||||
token := secret.Reveal(secret.ListenBrainzToken.Purpose(), key, *r.LbToken)
|
||||
if token == "" {
|
||||
unsendable(r.QueueID, "the saved ListenBrainz token can't be read; save it again in Settings")
|
||||
continue
|
||||
}
|
||||
ub = &userBatch{token: token, userID: r.UserID}
|
||||
|
||||
Reference in New Issue
Block a user