Improved LdapService thread safety, fixed user images sometimes not loading

This commit is contained in:
2025-11-24 11:02:58 +01:00
parent 22d72e124f
commit e9a55761c2
2 changed files with 70 additions and 25 deletions

View File

@@ -98,7 +98,6 @@ public class HomeController : Controller
[ResponseCache(Duration = 3600, Location = ResponseCacheLocation.Any, VaryByQueryKeys = new[] { "uid", "size" })]
public async Task<IActionResult> UserPhotoAsync(string uid, int? size)
{
Task<AdminSettingsModel> adminSettingsModelTask = _ldap.GetAdminSettingsModelAsync();
UserModel? user = await _ldap.GetUserByUidAsync(uid, _ldap.UsersAttributes);
if (user is null || user.JpegPhoto is null || user.JpegPhoto == "")
{
@@ -110,7 +109,7 @@ public class HomeController : Controller
}
if (size is not null)
{
AdminSettingsModel adminSettingsModel = await adminSettingsModelTask;
AdminSettingsModel adminSettingsModel = await _ldap.GetAdminSettingsModelAsync();
size = Math.Min((int)size, adminSettingsModel.MaxDownloadableUserImageSize);
}
byte[] encodedFile = ImageHelper.ResizeAndConvertToWebp(user.JpegPhoto, size ?? 32);