From de196a76872f534a07cddbcdccd6a1d50d0fbcd7 Mon Sep 17 00:00:00 2001
From: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
Date: Thu, 11 Aug 2022 14:02:51 -0700
Subject: [PATCH 1/2] Forces respecting IsVisible on people
---
Emby.Server.Implementations/Dto/DtoService.cs | 8 ++++++--
Emby.Server.Implementations/Library/LibraryManager.cs | 8 ++++++--
Jellyfin.Api/Controllers/PersonsController.cs | 5 ++++-
3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 09ba368514..3d2b8f7f63 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -182,7 +182,7 @@ namespace Emby.Server.Implementations.Dto
if (options.ContainsField(ItemFields.People))
{
- AttachPeople(dto, item);
+ AttachPeople(dto, item, user);
}
if (options.ContainsField(ItemFields.PrimaryImageAspectRatio))
@@ -503,7 +503,8 @@ namespace Emby.Server.Implementations.Dto
///
/// The dto.
/// The item.
- private void AttachPeople(BaseItemDto dto, BaseItem item)
+ /// The requesting user.
+ private void AttachPeople(BaseItemDto dto, BaseItem item, User user = null)
{
// Ordering by person type to ensure actors and artists are at the front.
// This is taking advantage of the fact that they both begin with A
@@ -560,6 +561,9 @@ namespace Emby.Server.Implementations.Dto
return null;
}
}).Where(i => i != null)
+ .Where(i => user == null ?
+ true :
+ i.IsVisible(user))
.GroupBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
.Select(x => x.First())
.ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 2843fb8f83..1c1f774375 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -2766,7 +2766,8 @@ namespace Emby.Server.Implementations.Library
public List GetPeopleItems(InternalPeopleQuery query)
{
- return _itemRepository.GetPeopleNames(query).Select(i =>
+ return _itemRepository.GetPeopleNames(query)
+ .Select(i =>
{
try
{
@@ -2777,7 +2778,10 @@ namespace Emby.Server.Implementations.Library
_logger.LogError(ex, "Error getting person");
return null;
}
- }).Where(i => i != null).ToList();
+ })
+ .Where(i => i.IsVisible(query.User))
+ .Where(i => i != null)
+ .ToList();
}
public List GetPeopleNames(InternalPeopleQuery query)
diff --git a/Jellyfin.Api/Controllers/PersonsController.cs b/Jellyfin.Api/Controllers/PersonsController.cs
index be4b9eded5..33f1aea394 100644
--- a/Jellyfin.Api/Controllers/PersonsController.cs
+++ b/Jellyfin.Api/Controllers/PersonsController.cs
@@ -98,7 +98,10 @@ namespace Jellyfin.Api.Controllers
Limit = limit ?? 0
});
- return new QueryResult(peopleItems.Select(person => _dtoService.GetItemByNameDto(person, dtoOptions, null, user)).ToArray());
+ return new QueryResult(
+ peopleItems
+ .Select(person => _dtoService.GetItemByNameDto(person, dtoOptions, null, user))
+ .ToArray());
}
///
From 2920c52d61225d077c031be6abe52670f984d6ef Mon Sep 17 00:00:00 2001
From: LogicalPhallacy <44458166+LogicalPhallacy@users.noreply.github.com>
Date: Thu, 11 Aug 2022 14:12:27 -0700
Subject: [PATCH 2/2] Reorder and check for query user null to avoid null ref
issues
---
Emby.Server.Implementations/Library/LibraryManager.cs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs
index 1c1f774375..12455e71ed 100644
--- a/Emby.Server.Implementations/Library/LibraryManager.cs
+++ b/Emby.Server.Implementations/Library/LibraryManager.cs
@@ -2779,8 +2779,10 @@ namespace Emby.Server.Implementations.Library
return null;
}
})
- .Where(i => i.IsVisible(query.User))
.Where(i => i != null)
+ .Where(i => query.User == null ?
+ true :
+ i.IsVisible(query.User))
.ToList();
}