aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/PlaystateService.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-12-18 00:44:33 -0500
committerGitHub <noreply@github.com>2016-12-18 00:44:33 -0500
commite7cebb91a73354dc3e0d0b6340c9fbd6511f4406 (patch)
tree6f1c368c766c17b7514fe749c0e92e69cd89194a /MediaBrowser.Api/UserLibrary/PlaystateService.cs
parent025905a3e4d50b9a2e07fbf4ff0a203af6604ced (diff)
parentaaa027f3229073e9a40756c3157d41af2a442922 (diff)
Merge pull request #2350 from MediaBrowser/beta
Beta
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);