mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-12-01 02:12:50 +08:00
The order was hardcoded: own account → assigned account → shared. That is the right default (privacy first), but it leaves one common case stuck: a member's own NetEase login is real but has no membership, while the admin's does. They linked their account, so playback keeps using theirs, and every paid track fails — with no way to say "just use the admin's for playback". Two things now: 1. An explicit choice — `user_music_prefs` (userId + platform), exposed as GET/PUT `/api/me/music/:platform/preference` and a radio in the account card. `preferShared: true` outranks EVERYTHING, including `alwaysPersonal` (someone who chose membership over their own recommendations wants the shared login for FM too). It stores a flag, not a cookie — flipping it back restores the personal account untouched. 2. An automatic fallback for people who never touch the switch. Only `getSongUrl` is wrapped: if the personal account returns `url: null` or throws, the same track is retried once on the shared login. Search, playlists and FM stay on the member's own account — that is the point of per-user logins, and widening the fallback would leak their library back to the admin's. Details: - The fallback lives in `resolveProviderForRequest`, so every playback entry point (web click, chat !play, auto-advance, playlists) gets it by construction, and the shared instance is never mutated. - `fallbackToShared: false` is available for callers that must stay strictly on the member's account; the default is on, because "my account has no VIP" is the complaint that produced this feature. - The status payload now carries `preferShared` and `featureEnabled`, so the UI can render the radio without a second round-trip and hide it when the admin has the feature off (PUT answers 409 in that case). 13 new tests: preference overrides own + assigned + alwaysPersonal, feature-off ignored, GET/PUT round-trip, per-platform isolation, stored cookie untouched, non-boolean rejected, 409 when disabled; fallback on null, on throw, keeps the personal result when it works, can be disabled, leaves the shared instance untouched.