| | | 1 | | using Jellyfin.Data.Enums; |
| | | 2 | | using Jellyfin.Database.Implementations.Entities; |
| | | 3 | | using MediaBrowser.Controller.Entities; |
| | | 4 | | using MediaBrowser.Controller.Library; |
| | | 5 | | |
| | | 6 | | namespace Emby.Server.Implementations.Library.SimilarItems; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Builds the access filter that decides which items a similar-items lookup may return for a user. |
| | | 10 | | /// </summary> |
| | | 11 | | internal static class SimilarItemsAccessFilter |
| | | 12 | | { |
| | 0 | 13 | | private static readonly BaseItemKind[] _itemByNameKinds = |
| | 0 | 14 | | [ |
| | 0 | 15 | | BaseItemKind.Person, |
| | 0 | 16 | | BaseItemKind.Genre, |
| | 0 | 17 | | BaseItemKind.MusicGenre, |
| | 0 | 18 | | BaseItemKind.MusicArtist, |
| | 0 | 19 | | BaseItemKind.Studio |
| | 0 | 20 | | ]; |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Builds an access filter carrying the user's library access and parental restrictions. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="user">The user the lookup runs for.</param> |
| | | 26 | | /// <param name="libraryManager">The library manager.</param> |
| | | 27 | | /// <returns>The access filter.</returns> |
| | | 28 | | public static InternalItemsQuery Build(User user, ILibraryManager libraryManager) |
| | | 29 | | { |
| | | 30 | | // IncludeItemTypes is read only for the by-name exemption here; the caller applies this |
| | | 31 | | // filter through ApplyAccessFiltering, which does not translate it into a type restriction. |
| | 0 | 32 | | var accessFilter = new InternalItemsQuery(user) |
| | 0 | 33 | | { |
| | 0 | 34 | | IncludeItemTypes = _itemByNameKinds |
| | 0 | 35 | | }; |
| | | 36 | | |
| | | 37 | | // ConfigureUserAccess populates TopParentIds for the libraries the user may open. |
| | 0 | 38 | | libraryManager.ConfigureUserAccess(accessFilter, user); |
| | | 39 | | |
| | 0 | 40 | | return accessFilter; |
| | | 41 | | } |
| | | 42 | | } |