/
/
/
# What does this implement/fix? A player works out its active group, its sync leader and which players it can be grouped with by scanning the other players. That scan went through the regular "list players" helper, which only returns the players the current user is allowed to see. Since the user context of an API command carries into everything that command touches, a state recalculation triggered by a non-admin user (or by an automation impersonating one) could not see the other players involved. The wrong answer was then stored as the player's state and sent to everyone, so a speaker could show up as not grouped, or refuse to be grouped, until something else recalculated it. Follow-up to #5393, which fixed the same problem for the group state fan-out. **Related issue (if applicable):** - n/a (found while reviewing #5385) ## Types of changes - [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [x] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ### Changes - Added `iter_players()`, which returns every registered player regardless of who is asking, and turned `all_players()` into a thin wrapper that applies the user filter on top of it — so the filter now lives in one place instead of being something each caller has to remember to avoid. - Use it when working out a player's sync leader, active group and groupable players, and when ungrouping a player. - A provider's own player list now uses it too. That list feeds the grouping options a provider offers (AirPlay derives them straight from it), and also drives the group-related refresh of every player of a provider. For protocol players it emptied out completely, because their ids never appear in a user's filter. - Same for the sync group's fallback list of groupable players, used when a group has no available members. - Simplified the group lookup added in #5393 to reuse the same iterator. - Updated the test doubles that stand in for the players controller. ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have [raised a PR against the documentation repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md) targeting the main or beta branch as appropriate.