release / govulncheck (push) Successful in 15s
release / web (push) Failing after 1m21s
release / go (push) Successful in 1m35s
release / integration (push) Failing after 4m57s
release / android (push) Successful in 5m11s
release / Build signed APK (releases and dev) (push) Successful in 5m28s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
Minstrel keeps its own list of what it is to get, keyed by MusicBrainz release group. A want comes from an approved request, a new release by a followed artist, or an album whose files went missing, and is held once the library has a full edition of it. - Migration 0081: release_type_profiles (Standard seeded: Album, EP, Single, studio only), follows, follow_seen_groups and wants. lidarr_requests becomes requests with plain *_mbid columns; approved album and track requests move onto the wanted list, approved artist requests become follows, and the library's album artists start out followed. missing_reacquisitions and the retry settings go. - internal/wanted: follows are checked against MusicBrainz discographies daily. The first check sets a baseline, and only releases after it are wanted unless the follow asked for what already exists. Profiles filter by primary and secondary type, so live recordings stay out unless a profile ticks Live. - internal/requests (was lidarrrequests): approving puts the request on the wanted list, and an artist request can be approved on a chosen profile. A request completes when its want is held. - The re-acquisition sweeper wants a missing album back instead of asking Lidarr; searching for it is the search schedule's (#5521). - Web: an admin Wanted page (Wanted, Missing files, Held, Following), a follow control on artist pages, a release-type profiles card on Integrations, "Approve on a profile" on Requests, and want state on Missing files. The artist detail API returns the artist's MBID. - Android: the request body sends artist_mbid, album_mbid and track_mbid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
87 lines
2.6 KiB
Go
87 lines
2.6 KiB
Go
package api
|
||
|
||
import (
|
||
"context"
|
||
|
||
"github.com/jackc/pgx/v5/pgtype"
|
||
|
||
"git.fabledsword.com/bvandeusen/minstrel/internal/db/dbq"
|
||
"git.fabledsword.com/bvandeusen/minstrel/internal/notifications"
|
||
"git.fabledsword.com/bvandeusen/minstrel/internal/requests"
|
||
)
|
||
|
||
// Helpers for the handlers that produce notifications (M489). Every call is
|
||
// NotifyLogged: a notification never fails the action that caused it.
|
||
|
||
// userLabel is how a user is named to someone else: their display name, or
|
||
// their username when they have none.
|
||
func userLabel(u dbq.User) string {
|
||
if u.DisplayName != nil && *u.DisplayName != "" {
|
||
return *u.DisplayName
|
||
}
|
||
return u.Username
|
||
}
|
||
|
||
func requestPayload(row dbq.Request) notifications.Payload {
|
||
return notifications.Payload{
|
||
RequestID: uuidToString(row.ID),
|
||
RequestKind: string(row.Kind),
|
||
Name: requests.DisplayName(row),
|
||
}
|
||
}
|
||
|
||
// notifyRequestDecided tells the requester an admin approved or declined
|
||
// their request. An admin deciding their own request needs no notice.
|
||
func (h *handlers) notifyRequestDecided(ctx context.Context, kind notifications.Kind, admin dbq.User, row dbq.Request, reason string) {
|
||
if row.UserID == admin.ID {
|
||
return
|
||
}
|
||
p := requestPayload(row)
|
||
p.Reason = reason
|
||
h.notifier.NotifyLogged(ctx, kind, notifications.ToUser(row.UserID), p.Map())
|
||
}
|
||
|
||
// quarantineReasonLabel is a flag reason as the flag popover words it, in
|
||
// lower case to sit inside a sentence ("flagged X: bad rip").
|
||
func quarantineReasonLabel(reason string) string {
|
||
switch reason {
|
||
case "bad_rip":
|
||
return "bad rip"
|
||
case "wrong_file":
|
||
return "wrong file"
|
||
case "wrong_tags":
|
||
return "wrong tags"
|
||
case "duplicate":
|
||
return "duplicate"
|
||
default:
|
||
return ""
|
||
}
|
||
}
|
||
|
||
// trackLabel names a track "Artist – Title" for a notification, falling back
|
||
// to the title alone, or to nothing, rather than failing the caller.
|
||
func (h *handlers) trackLabel(ctx context.Context, trackID pgtype.UUID) string {
|
||
q := dbq.New(h.pool)
|
||
t, err := q.GetTrackByID(ctx, trackID)
|
||
if err != nil {
|
||
return ""
|
||
}
|
||
if a, aerr := q.GetArtistByID(ctx, t.ArtistID); aerr == nil && a.Name != "" {
|
||
return a.Name + " – " + t.Title
|
||
}
|
||
return t.Title
|
||
}
|
||
|
||
// notifyPlaybackErrors tells admins how many playback errors await review.
|
||
// The notice coalesces, so while it is unread a new report only updates the
|
||
// count.
|
||
func (h *handlers) notifyPlaybackErrors(ctx context.Context) {
|
||
n, err := dbq.New(h.pool).CountUnresolvedPlaybackErrors(ctx)
|
||
if err != nil {
|
||
h.logger.Warn("api: playback_error: count unresolved", "err", err)
|
||
return
|
||
}
|
||
h.notifier.NotifyLogged(ctx, notifications.KindPlaybackErrors, notifications.ToAdmins(pgtype.UUID{}),
|
||
notifications.Payload{Count: n}.Map())
|
||
}
|