fix(lidarrquarantine): keep LidarrAlbumMbid nil on Resolve/DeleteFile audit rows + cover idempotent Resolve
The audit log treats lidarr_album_mbid as a 'this row triggered Lidarr' marker. Setting it on Resolve/DeleteFile (where Lidarr is never contacted) muddied that semantic. Reverting to plan: only DeleteViaLidarr writes the mbid. Adds an idempotency test for Resolve over a track with zero rows (audit row written, affected_users=0, mbid nil).
This commit is contained in:
@@ -205,10 +205,13 @@ func (s *Service) Resolve(ctx context.Context, trackID, adminID pgtype.UUID) (db
|
||||
if err := q.DeleteQuarantineForTrack(ctx, trackID); err != nil {
|
||||
return dbq.LidarrQuarantineAction{}, fmt.Errorf("delete rows: %w", err)
|
||||
}
|
||||
// LidarrAlbumMbid stays nil here: Lidarr was not contacted. The audit
|
||||
// log uses the field as a "this row triggered Lidarr" marker, so only
|
||||
// DeleteViaLidarr sets it.
|
||||
return q.WriteQuarantineAction(ctx, dbq.WriteQuarantineActionParams{
|
||||
TrackID: trackID, TrackTitle: snap.TrackTitle, ArtistName: snap.ArtistName,
|
||||
AlbumTitle: snap.AlbumTitle, Action: dbq.LidarrQuarantineActionKindResolved,
|
||||
AdminID: adminID, LidarrAlbumMbid: snap.LidarrAlbumMBID, AffectedUsers: affected,
|
||||
AdminID: adminID, LidarrAlbumMbid: nil, AffectedUsers: affected,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -269,11 +272,12 @@ func (s *Service) DeleteFile(ctx context.Context, trackID, adminID pgtype.UUID)
|
||||
}
|
||||
// tracks row is gone; ON DELETE CASCADE on lidarr_quarantine.track_id
|
||||
// already cleared the per-user rows. We don't call
|
||||
// DeleteQuarantineForTrack separately.
|
||||
// DeleteQuarantineForTrack separately. LidarrAlbumMbid stays nil —
|
||||
// Lidarr was not contacted.
|
||||
return q.WriteQuarantineAction(ctx, dbq.WriteQuarantineActionParams{
|
||||
TrackID: trackID, TrackTitle: snap.TrackTitle, ArtistName: snap.ArtistName,
|
||||
AlbumTitle: snap.AlbumTitle, Action: dbq.LidarrQuarantineActionKindDeletedFile,
|
||||
AdminID: adminID, LidarrAlbumMbid: snap.LidarrAlbumMBID, AffectedUsers: affected,
|
||||
AdminID: adminID, LidarrAlbumMbid: nil, AffectedUsers: affected,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user