aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/PlaystateService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/PlaystateService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/PlaystateService.cs20
1 files changed, 12 insertions, 8 deletions
diff --git a/MediaBrowser.Api/UserLibrary/PlaystateService.cs b/MediaBrowser.Api/UserLibrary/PlaystateService.cs
index 710d337ec..5fe6c1771 100644
--- a/MediaBrowser.Api/UserLibrary/PlaystateService.cs
+++ b/MediaBrowser.Api/UserLibrary/PlaystateService.cs
@@ -4,11 +4,11 @@ using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Session;
-using ServiceStack;
using System;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
+using MediaBrowser.Model.Services;
namespace MediaBrowser.Api.UserLibrary
{
@@ -234,13 +234,17 @@ namespace MediaBrowser.Api.UserLibrary
private readonly IUserDataManager _userDataRepository;
private readonly ILibraryManager _libraryManager;
private readonly ISessionManager _sessionManager;
+ private readonly ISessionContext _sessionContext;
+ private readonly IAuthorizationContext _authContext;
- public PlaystateService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, ISessionManager sessionManager)
+ public PlaystateService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, ISessionManager sessionManager, ISessionContext sessionContext, IAuthorizationContext authContext)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_sessionManager = sessionManager;
+ _sessionContext = sessionContext;
+ _authContext = authContext;
}
/// <summary>
@@ -265,7 +269,7 @@ namespace MediaBrowser.Api.UserLibrary
datePlayed = DateTime.ParseExact(request.DatePlayed, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
}
- var session = await GetSession().ConfigureAwait(false);
+ var session = await GetSession(_sessionContext).ConfigureAwait(false);
var dto = await UpdatePlayedStatus(user, request.Id, true, datePlayed).ConfigureAwait(false);
@@ -303,7 +307,7 @@ namespace MediaBrowser.Api.UserLibrary
public void Post(ReportPlaybackStart request)
{
- request.SessionId = GetSession().Result.Id;
+ request.SessionId = GetSession(_sessionContext).Result.Id;
var task = _sessionManager.OnPlaybackStart(request);
@@ -335,7 +339,7 @@ namespace MediaBrowser.Api.UserLibrary
public void Post(ReportPlaybackProgress request)
{
- request.SessionId = GetSession().Result.Id;
+ request.SessionId = GetSession(_sessionContext).Result.Id;
var task = _sessionManager.OnPlaybackProgress(request);
@@ -369,10 +373,10 @@ namespace MediaBrowser.Api.UserLibrary
if (!string.IsNullOrWhiteSpace(request.PlaySessionId))
{
- ApiEntryPoint.Instance.KillTranscodingJobs(AuthorizationContext.GetAuthorizationInfo(Request).DeviceId, request.PlaySessionId, s => true);
+ ApiEntryPoint.Instance.KillTranscodingJobs(_authContext.GetAuthorizationInfo(Request).DeviceId, request.PlaySessionId, s => true);
}
- request.SessionId = GetSession().Result.Id;
+ request.SessionId = GetSession(_sessionContext).Result.Id;
var task = _sessionManager.OnPlaybackStopped(request);
@@ -394,7 +398,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
- var session = await GetSession().ConfigureAwait(false);
+ var session = await GetSession(_sessionContext).ConfigureAwait(false);
var dto = await UpdatePlayedStatus(user, request.Id, false, null).ConfigureAwait(false);