4381 Commits

Author SHA1 Message Date
Deluan
389971e151 fix formating
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:42 -03:00
Deluan
50da0d8069 fix: improve cache buffering logic
Refactored the cache buffering logic to ensure thread safety when checking
the buffer length

Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:42 -03:00
Deluan
ea8fe8c044 fix: correct updated_at assignment in library repository
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:42 -03:00
Deluan
6b8fc4b9a0 feat: add default library assignment for new users
Introduced a new column `default_new_users` in the library table to
facilitate automatic assignment of default libraries to new regular users.
When a new user is created, they will now be assigned to libraries marked
as default, enhancing user experience by ensuring they have immediate access
to essential resources. Additionally, updated the user repository logic
to handle this new functionality and modified the user creation validation
to reflect that library selection is optional for non-admin users.

Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
9b98e5a9b3 feat: enhance library selection with master checkbox functionality
Added a master checkbox to the SelectLibraryInput component, allowing users to select or deselect all libraries at once. This improves user experience by simplifying the selection process when multiple libraries are available. Additionally, updated translations in the en.json file to include a new message for selecting all libraries, ensuring consistency in user interface messaging.

Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
2e8daa82f7 chore: remove commented-out genre repository code from persistence tests 2025-07-10 17:51:41 -03:00
Deluan
ec22a7d0b7 feat: replace AddUserLibrary and RemoveUserLibrary with SetUserLibraries for better library management
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
3c1a466547 feat: enhance library management with refresh event broadcasting
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
619b70e239 feat: add useRefreshOnEvents hook for custom refresh logic on event changes
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
907ecd92c0 feat: add event broadcasting for library creation, update, and deletion
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
326154a786 refactor: implement SendBroadcastMessage method for event broadcasting
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
aaf60dfffd fix: allow editing name of main library
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
02f4723d01 feat: refresh LibraryList on scan end
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
2143e42ebc feat: add musicFolderId parameter support to Search2 and Search3 endpoints
Implemented musicFolderId parameter support for Subsonic API Search2 and Search3 endpoints, completing multi-library functionality across all Subsonic endpoints.

Key changes:
- Added musicFolderId parameter handling to Search2 and Search3 endpoints
- Updated search logic to filter results by specified library or all accessible libraries when parameter not provided
- Added proper error handling for invalid/inaccessible musicFolderId values
- Refactored SearchableRepository interface to support library filtering with variadic QueryOptions
- Updated repository implementations (Album, Artist, MediaFile) to handle library filtering in search operations
- Added comprehensive test coverage with robust assertions verifying library filtering works correctly
- Enhanced mock repositories to capture QueryOptions for test validation

Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
6e38506bbf fix: return error when any musicFolderId is invalid or inaccessible
Changed behavior from silently filtering invalid library IDs to returning
ErrorDataNotFound (code 70) when any provided musicFolderId parameter
is invalid or the user doesn't have access to it.

The error message includes the specific library number for better debugging.
This affects album/song list endpoints (getAlbumList, getRandomSongs,
getSongsByGenre, getStarred) to provide consistent error handling
across all Subsonic API endpoints.

Updated corresponding tests to expect errors instead of silent filtering.
2025-07-10 17:51:41 -03:00
Deluan
86035d053c feat: enhance artist library filtering based on user permissions and optimize library ID retrieval
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
763e0f18be feat: implement library access filtering for artist queries based on user permissions
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
7fdfe9d8eb feat: add library access methods to User model
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
c69c77c249 fix: add ApplyArtistLibraryFilter to filter artists by associated music folders
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
bee6305add refactor: optimize starred items queries with parallel execution and fix test isolation
Refactored starred items functionality by extracting common logic into getStarredItems()
method that executes artist, album, and media file queries in parallel for better performance.
This eliminates code duplication between GetStarred and GetStarred2 methods while improving
response times through concurrent database queries using run.Parallel().

Also fixed test isolation issues by adding missing auth.Init(ds) call in album lists test setup.
This resolves nil pointer dereference errors in GetStarred and GetStarred2 tests when run independently.
2025-07-10 17:51:41 -03:00
Deluan
b9de229864 feat: implement multi-library support for GetRandomSongs, GetSongsByGenre, GetStarred, and GetStarred2
- Added multi-library filtering to GetRandomSongs endpoint using musicFolderId parameter
- Added multi-library filtering to GetSongsByGenre endpoint using musicFolderId parameter
- Enhanced GetStarred and GetStarred2 to filter artists, albums, and songs by library
- Added Options field to MockMediaFileRepo and MockArtistRepo for test compatibility
- Added comprehensive Ginkgo/Gomega tests for all new multi-library functionality
- All tests verify proper SQL filter generation and library access validation
- Supports single/multiple musicFolderId values with fallback to all accessible libraries
2025-07-10 17:51:41 -03:00
Deluan
c787a62afd feat: implement multi-library support for GetAlbumList and GetAlbumList2 endpoints
- Enhanced selectedMusicFolderIds helper to validate and filter library IDs
- Added ApplyLibraryFilter function in filter/filters.go for library filtering
- Updated getAlbumList to support musicFolderId parameter filtering
- Added comprehensive tests for multi-library functionality
- Supports single and multiple musicFolderId values
- Falls back to all accessible libraries when no musicFolderId provided
- Validates library access permissions for user security
2025-07-10 17:51:41 -03:00
Deluan
1fdc4cf246 feat: add library access validation to selectedMusicFolderIds
Enhanced the selectedMusicFolderIds function to validate musicFolderId parameters
against the user's accessible libraries. Invalid library IDs (those the user
doesn't have access to) are now silently filtered out, improving security by
preventing users from accessing libraries they don't have permission for.

Changes include:
- Added validation logic to check musicFolderId parameters against user's accessible libraries
- Added slices package import for efficient validation
- Enhanced function documentation to clarify validation behavior
- Added comprehensive test cases covering validation scenarios
- Maintains backward compatibility with existing behavior
2025-07-10 17:51:41 -03:00
Deluan
cfc1a93118 refactor: change ArtistRepository.GetIndex to accept multiple library IDs
Updated the GetIndex method signature to accept a slice of library IDs instead of a single ID, enabling support for filtering artists across multiple libraries simultaneously.

Changes include:
- Modified ArtistRepository interface in model/artist.go
- Updated implementation in persistence/artist_repository.go with improved library filtering logic
- Refactored Subsonic API browsing.go to use new selectedMusicFolderIds helper
- Added comprehensive test coverage for multiple library scenarios
- Updated mock repository implementation for testing

This change improves flexibility for multi-library operations while maintaining backward compatibility through the selectedMusicFolderIds helper function.
2025-07-10 17:51:41 -03:00
Deluan
442c1b1e1f feat: enhance selectedMusicFolderIds function to handle valid music folder IDs and improve fallback logic
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
6538d24e45 refactor: simplify getUserAccessibleLibraries function and update related tests
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
d0aceb2f08 fix: ensure LibrarySelector dropdown refreshes on button close
Added refresh() call when closing the dropdown via button click to maintain
consistency with the ClickAwayListener behavior. This ensures the UI
updates properly regardless of how the dropdown is closed, fixing an
inconsistent refresh behavior between different closing methods.

The fix tracks the previous open state and calls refresh() only when
the dropdown was open and is being closed by the button click.
2025-07-10 17:51:41 -03:00
Deluan
45b0d56707 feat(subsonic): update GetIndexes and GetArtists method to support library ID filtering
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
c17b931f39 feat(library): enhance LibrarySelectionField to extract library IDs from record
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
0a051db851 feat(subsonic): implement user-specific library access in GetMusicFolders
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
1e860524d5 Add library_id field support for smart playlists
- Add library_id field to smart playlist criteria system
- Supports Is and IsNot operators for filtering by library ID
- Includes comprehensive test coverage for single values and lists
- Enables creation of library-specific smart playlists
2025-07-10 17:51:41 -03:00
Deluan
bdf484d980 feat(artist): add library ID filtering for artists in repository and update resource filtering logic
Signed-off-by: Deluan <deluan@navidrome.org>

# Conflicts:
#	persistence/artist_repository.go
2025-07-10 17:51:41 -03:00
Deluan
41c6c1551b feat(library): add refresh functionality on LibrarySelector close
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
37c6a71a0d fix(repository): add table name handling in filter functions for SQL queries
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
1cbbc3e904 feat(library): streamline library ID filtering in repositories and update resource filtering logic
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
381f58a4a8 feat(library): add library ID filtering for album resources
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
75df035edb test: add unit tests for file utility functions
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
ad31d8f679 feat(library): add tests for LibrarySelector and library selection hooks
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
b01719fece feat(library): implement library selection functionality with reducer and UI component
Signed-off-by: Deluan <deluan@navidrome.org>

# Conflicts:
#	.github/copilot-instructions.md

# Conflicts:
#	.gitignore
2025-07-10 17:51:41 -03:00
Deluan
12bd7b6466 feat(user): add library selection for user creation and editing
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
1486163c92 feat(repository): apply library filtering in CountAll methods for albums, folders, and media files
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
6015ac2e41 prepend libraryID for track and album PIDs
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
4389b34e3e fix: track processed libraries by updating state with scan timestamps
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
8c89f0e41d refactor(scanner): streamline library handling by using state-libraries for consistency
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
e01ef006f3 feat(library): add/remove watchers on demand, not only when server starts
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
be868c47fe feat(library): add library path and name fields to album and mediafile models
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
0631ac33d8 refactor: move scan triggering logic into a helper method for clarity
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
05f32f0d76 rename migration file for user library table to maintain versioning order
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
6a3efc7e14 feat(library): trigger scan after successful library deletion to clean up orphaned data
Signed-off-by: Deluan <deluan@navidrome.org>
2025-07-10 17:51:41 -03:00
Deluan
38e1d3f88f feat(library): implement scanner interface for triggering library scans on create/update
Signed-off-by: Deluan <deluan@navidrome.org>

# Conflicts:
#	cmd/wire_gen.go
#	cmd/wire_injectors.go

# Conflicts:
#	cmd/wire_gen.go

# Conflicts:
#	cmd/wire_gen.go
#	cmd/wire_injectors.go
2025-07-10 17:51:41 -03:00