From 03b8b15f6e27d2de9da949a2bef68f5fa541ad87 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 24 May 2026 20:01:45 -0300 Subject: [PATCH] feat(participants): add DisplayName method to prioritize CreditedAs over Name Signed-off-by: Deluan --- model/participants.go | 4 ++++ server/subsonic/helpers.go | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/model/participants.go b/model/participants.go index 772bea97a..4db198b61 100644 --- a/model/participants.go +++ b/model/participants.go @@ -81,6 +81,10 @@ type Participant struct { CreditedAs string `json:"creditedAs,omitempty"` } +func (p Participant) DisplayName() string { + return cmp.Or(p.CreditedAs, p.Name) +} + type ParticipantList []Participant func (p ParticipantList) Join(sep string) string { diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go index da5c134bb..4bd2c427b 100644 --- a/server/subsonic/helpers.go +++ b/server/subsonic/helpers.go @@ -282,7 +282,7 @@ func osChildFromMediaFile(ctx context.Context, mf model.MediaFile) *responses.Op SubRole: participant.SubRole, Artist: responses.ArtistID3Ref{ Id: participant.ID, - Name: participantDisplayName(participant), + Name: participant.DisplayName(), }, }) } @@ -296,20 +296,11 @@ func artistRefs(participants model.ParticipantList) []responses.ArtistID3Ref { return slice.Map(participants, func(p model.Participant) responses.ArtistID3Ref { return responses.ArtistID3Ref{ Id: p.ID, - Name: participantDisplayName(p), + Name: p.DisplayName(), } }) } -// participantDisplayName returns CreditedAs if set, otherwise the canonical Name. -// Legacy rows (pre-rescan) have empty CreditedAs and continue to show canonical. -func participantDisplayName(p model.Participant) string { - if p.CreditedAs != "" { - return p.CreditedAs - } - return p.Name -} - func fakePath(mf model.MediaFile) string { builder := strings.Builder{}