fixes #566 - Add permission configuration for remote control

This commit is contained in:
Luke Pulverenti 2013-10-30 11:55:55 -04:00
parent ee912d4113
commit 2f99b2e1e6
2 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
using ServiceStack.ServiceHost;
@ -182,16 +183,18 @@ namespace MediaBrowser.Api
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
private readonly IUserManager _userManager;
/// <summary>
/// Initializes a new instance of the <see cref="SessionsService" /> class.
/// </summary>
/// <param name="sessionManager">The session manager.</param>
/// <param name="dtoService">The dto service.</param>
public SessionsService(ISessionManager sessionManager, IDtoService dtoService)
public SessionsService(ISessionManager sessionManager, IDtoService dtoService, IUserManager userManager)
{
_sessionManager = sessionManager;
_dtoService = dtoService;
_userManager = userManager;
}
/// <summary>
@ -208,6 +211,16 @@ namespace MediaBrowser.Api
result = result.Where(i => i.SupportsRemoteControl == request.SupportsRemoteControl.Value);
}
if (request.ControllableByUserId.HasValue)
{
var user = _userManager.GetUserById(request.ControllableByUserId.Value);
if (!user.Configuration.EnableRemoteControlOfOtherUsers)
{
result = result.Where(i => i.User == null || i.User.Id == request.ControllableByUserId.Value);
}
}
return ToOptimizedResult(result.Select(_dtoService.GetSessionInfoDto).ToList());
}

View File

@ -58,6 +58,7 @@ namespace MediaBrowser.Model.Configuration
public bool DisplayMissingEpisodes { get; set; }
public bool DisplayUnairedEpisodes { get; set; }
public bool EnableRemoteControlOfOtherUsers { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="UserConfiguration" /> class.
@ -65,6 +66,7 @@ namespace MediaBrowser.Model.Configuration
public UserConfiguration()
{
IsAdministrator = true;
EnableRemoteControlOfOtherUsers = true;
BlockNotRated = false;
}
}