Allow explicitly set userId for RequestHelpers.GetSession (#11505)

This commit is contained in:
gnattu 2024-05-07 23:43:54 +08:00 committed by GitHub
parent 4044431610
commit 8c583bbe37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -90,7 +90,7 @@ public class PlaystateController : BaseJellyfinApiController
return NotFound();
}
var session = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
var session = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext, userId).ConfigureAwait(false);
var dto = UpdatePlayedStatus(user, item, true, datePlayed);
foreach (var additionalUserInfo in session.AdditionalUsers)
@ -155,7 +155,7 @@ public class PlaystateController : BaseJellyfinApiController
return NotFound();
}
var session = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext).ConfigureAwait(false);
var session = await RequestHelpers.GetSession(_sessionManager, _userManager, HttpContext, userId).ConfigureAwait(false);
var dto = UpdatePlayedStatus(user, item, false, null);
foreach (var additionalUserInfo in session.AdditionalUsers)

View File

@ -117,10 +117,10 @@ public static class RequestHelpers
return user.EnableUserPreferenceAccess;
}
internal static async Task<SessionInfo> GetSession(ISessionManager sessionManager, IUserManager userManager, HttpContext httpContext)
internal static async Task<SessionInfo> GetSession(ISessionManager sessionManager, IUserManager userManager, HttpContext httpContext, Guid? userId = null)
{
var userId = httpContext.User.GetUserId();
var user = userManager.GetUserById(userId);
userId ??= httpContext.User.GetUserId();
var user = userManager.GetUserById(userId.Value);
var session = await sessionManager.LogSessionActivity(
httpContext.User.GetClient(),
httpContext.User.GetVersion(),