diff --git a/Jellyfin.Api/Controllers/PlaystateController.cs b/Jellyfin.Api/Controllers/PlaystateController.cs index 9d6d756818..88aa0178f9 100644 --- a/Jellyfin.Api/Controllers/PlaystateController.cs +++ b/Jellyfin.Api/Controllers/PlaystateController.cs @@ -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) diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index 429e972132..b607e91041 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -117,10 +117,10 @@ public static class RequestHelpers return user.EnableUserPreferenceAccess; } - internal static async Task GetSession(ISessionManager sessionManager, IUserManager userManager, HttpContext httpContext) + internal static async Task 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(),