mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 05:47:14 -04:00
add user permissions for managing tv recordings
This commit is contained in:
parent
c822bfc0cd
commit
e206f27839
@ -81,6 +81,14 @@ namespace MediaBrowser.Api
|
|||||||
return GetAuthorization(auth);
|
return GetAuthorization(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static User GetCurrentUser(IRequest httpReq, IUserManager userManager)
|
||||||
|
{
|
||||||
|
var info = GetAuthorization(httpReq);
|
||||||
|
|
||||||
|
return string.IsNullOrEmpty(info.UserId) ? null :
|
||||||
|
userManager.GetUserById(new Guid(info.UserId));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the authorization.
|
/// Gets the authorization.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -275,6 +275,21 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
_userManager = userManager;
|
_userManager = userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AssertUserCanManageLiveTv()
|
||||||
|
{
|
||||||
|
var user = AuthorizationRequestFilterAttribute.GetCurrentUser(Request, _userManager);
|
||||||
|
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
throw new UnauthorizedAccessException("Anonymous live tv management is not allowed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.Configuration.EnableLiveTvManagement)
|
||||||
|
{
|
||||||
|
throw new UnauthorizedAccessException("The current user does not have permission to manage live tv.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public object Get(GetServices request)
|
public object Get(GetServices request)
|
||||||
{
|
{
|
||||||
var services = _liveTvManager.Services
|
var services = _liveTvManager.Services
|
||||||
@ -415,6 +430,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Delete(DeleteRecording request)
|
public void Delete(DeleteRecording request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.DeleteRecording(request.Id);
|
var task = _liveTvManager.DeleteRecording(request.Id);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -422,6 +439,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Delete(CancelTimer request)
|
public void Delete(CancelTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.CancelTimer(request.Id);
|
var task = _liveTvManager.CancelTimer(request.Id);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -429,6 +448,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Post(UpdateTimer request)
|
public void Post(UpdateTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.UpdateTimer(request, CancellationToken.None);
|
var task = _liveTvManager.UpdateTimer(request, CancellationToken.None);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -455,6 +476,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Delete(CancelSeriesTimer request)
|
public void Delete(CancelSeriesTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.CancelSeriesTimer(request.Id);
|
var task = _liveTvManager.CancelSeriesTimer(request.Id);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -462,6 +485,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Post(UpdateSeriesTimer request)
|
public void Post(UpdateSeriesTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.UpdateSeriesTimer(request, CancellationToken.None);
|
var task = _liveTvManager.UpdateSeriesTimer(request, CancellationToken.None);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -494,6 +519,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Post(CreateSeriesTimer request)
|
public void Post(CreateSeriesTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.CreateSeriesTimer(request, CancellationToken.None);
|
var task = _liveTvManager.CreateSeriesTimer(request, CancellationToken.None);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
@ -501,6 +528,8 @@ namespace MediaBrowser.Api.LiveTv
|
|||||||
|
|
||||||
public void Post(CreateTimer request)
|
public void Post(CreateTimer request)
|
||||||
{
|
{
|
||||||
|
AssertUserCanManageLiveTv();
|
||||||
|
|
||||||
var task = _liveTvManager.CreateTimer(request, CancellationToken.None);
|
var task = _liveTvManager.CreateTimer(request, CancellationToken.None);
|
||||||
|
|
||||||
Task.WaitAll(task);
|
Task.WaitAll(task);
|
||||||
|
@ -119,11 +119,12 @@ namespace MediaBrowser.Controller.LiveTv
|
|||||||
Task<IEnumerable<TimerInfo>> GetTimersAsync(CancellationToken cancellationToken);
|
Task<IEnumerable<TimerInfo>> GetTimersAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the timer defaults asynchronous.
|
/// Gets the new timer defaults asynchronous.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task{TimerInfo}.</returns>
|
/// <param name="program">The program.</param>
|
||||||
Task<SeriesTimerInfo> GetNewTimerDefaultsAsync(CancellationToken cancellationToken);
|
/// <returns>Task{SeriesTimerInfo}.</returns>
|
||||||
|
Task<SeriesTimerInfo> GetNewTimerDefaultsAsync(CancellationToken cancellationToken, ProgramInfo program = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the series timers asynchronous.
|
/// Gets the series timers asynchronous.
|
||||||
|
@ -67,6 +67,8 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
public bool BlockUnratedGames { get; set; }
|
public bool BlockUnratedGames { get; set; }
|
||||||
public bool BlockUnratedBooks { get; set; }
|
public bool BlockUnratedBooks { get; set; }
|
||||||
|
|
||||||
|
public bool EnableLiveTvManagement { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UserConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="UserConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -75,6 +77,8 @@ namespace MediaBrowser.Model.Configuration
|
|||||||
IsAdministrator = true;
|
IsAdministrator = true;
|
||||||
EnableRemoteControlOfOtherUsers = true;
|
EnableRemoteControlOfOtherUsers = true;
|
||||||
BlockNotRated = false;
|
BlockNotRated = false;
|
||||||
|
|
||||||
|
EnableLiveTvManagement = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Without these movies that have the name season in them could cause the parent folder to be resolved as a series
|
// Without these movies that have the name season in them could cause the parent folder to be resolved as a series
|
||||||
if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 || filename.IndexOf("[tmdbid=", StringComparison.OrdinalIgnoreCase) != -1)
|
if (filename.IndexOf("[tmdbid=", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1011,24 +1011,31 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<SeriesTimerInfo> GetNewTimerDefaultsInternal(CancellationToken cancellationToken, ProgramInfo program = null)
|
||||||
|
{
|
||||||
|
var info = await ActiveService.GetNewTimerDefaultsAsync(cancellationToken, program).ConfigureAwait(false);
|
||||||
|
|
||||||
|
info.Id = null;
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(CancellationToken cancellationToken)
|
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var service = ActiveService;
|
var info = await GetNewTimerDefaultsInternal(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var info = await service.GetNewTimerDefaultsAsync(cancellationToken).ConfigureAwait(false);
|
var obj = _tvDtoService.GetSeriesTimerInfoDto(info, ActiveService, null);
|
||||||
|
|
||||||
var obj = _tvDtoService.GetSeriesTimerInfoDto(info, service, null);
|
|
||||||
|
|
||||||
obj.Id = obj.ExternalId = string.Empty;
|
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(string programId, CancellationToken cancellationToken)
|
public async Task<SeriesTimerInfoDto> GetNewTimerDefaults(string programId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var info = await GetNewTimerDefaults(cancellationToken).ConfigureAwait(false);
|
var program = GetInternalProgram(programId).ProgramInfo;
|
||||||
|
var programDto = await GetProgram(programId, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var program = await GetProgram(programId, cancellationToken).ConfigureAwait(false);
|
var defaults = await GetNewTimerDefaultsInternal(cancellationToken, program).ConfigureAwait(false);
|
||||||
|
var info = _tvDtoService.GetSeriesTimerInfoDto(defaults, ActiveService, null);
|
||||||
|
|
||||||
info.Days = new List<DayOfWeek>
|
info.Days = new List<DayOfWeek>
|
||||||
{
|
{
|
||||||
@ -1039,13 +1046,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||||||
|
|
||||||
info.Name = program.Name;
|
info.Name = program.Name;
|
||||||
info.ChannelId = program.ChannelId;
|
info.ChannelId = program.ChannelId;
|
||||||
info.ChannelName = program.ChannelName;
|
info.ChannelName = programDto.ChannelName;
|
||||||
info.EndDate = program.EndDate;
|
info.EndDate = program.EndDate;
|
||||||
info.StartDate = program.StartDate;
|
info.StartDate = program.StartDate;
|
||||||
info.Name = program.Name;
|
info.Name = program.Name;
|
||||||
info.Overview = program.Overview;
|
info.Overview = program.Overview;
|
||||||
info.ProgramId = program.Id;
|
info.ProgramId = program.Id;
|
||||||
info.ExternalProgramId = program.ExternalId;
|
info.ExternalProgramId = programDto.ExternalId;
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -378,6 +378,17 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.getAuthorizedFeatures = function (options) {
|
||||||
|
|
||||||
|
var url = self.getUrl("Users/AuthorizedFeatures", options || {});
|
||||||
|
|
||||||
|
return self.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: url,
|
||||||
|
dataType: "json"
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
self.getLiveTvServices = function (options) {
|
self.getLiveTvServices = function (options) {
|
||||||
|
|
||||||
var url = self.getUrl("LiveTv/Services", options || {});
|
var url = self.getUrl("LiveTv/Services", options || {});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.226" targetFramework="net45" />
|
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.228" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common.Internal</id>
|
<id>MediaBrowser.Common.Internal</id>
|
||||||
<version>3.0.299</version>
|
<version>3.0.300</version>
|
||||||
<title>MediaBrowser.Common.Internal</title>
|
<title>MediaBrowser.Common.Internal</title>
|
||||||
<authors>Luke</authors>
|
<authors>Luke</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.299" />
|
<dependency id="MediaBrowser.Common" version="3.0.300" />
|
||||||
<dependency id="NLog" version="2.1.0" />
|
<dependency id="NLog" version="2.1.0" />
|
||||||
<dependency id="SimpleInjector" version="2.4.0" />
|
<dependency id="SimpleInjector" version="2.4.0" />
|
||||||
<dependency id="sharpcompress" version="0.10.2" />
|
<dependency id="sharpcompress" version="0.10.2" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Common</id>
|
<id>MediaBrowser.Common</id>
|
||||||
<version>3.0.299</version>
|
<version>3.0.300</version>
|
||||||
<title>MediaBrowser.Common</title>
|
<title>MediaBrowser.Common</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>MediaBrowser.Server.Core</id>
|
<id>MediaBrowser.Server.Core</id>
|
||||||
<version>3.0.299</version>
|
<version>3.0.300</version>
|
||||||
<title>Media Browser.Server.Core</title>
|
<title>Media Browser.Server.Core</title>
|
||||||
<authors>Media Browser Team</authors>
|
<authors>Media Browser Team</authors>
|
||||||
<owners>ebr,Luke,scottisafool</owners>
|
<owners>ebr,Luke,scottisafool</owners>
|
||||||
@ -12,7 +12,7 @@
|
|||||||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||||
<copyright>Copyright © Media Browser 2013</copyright>
|
<copyright>Copyright © Media Browser 2013</copyright>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency id="MediaBrowser.Common" version="3.0.299" />
|
<dependency id="MediaBrowser.Common" version="3.0.300" />
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</metadata>
|
</metadata>
|
||||||
<files>
|
<files>
|
||||||
|
Loading…
Reference in New Issue
Block a user