mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
commit
fed5ad43dd
169 changed files with 5842 additions and 618 deletions
131
CHANGELOG.md
131
CHANGELOG.md
|
@ -1,7 +1,138 @@
|
|||
# Changelog
|
||||
|
||||
## (unreleased)
|
||||
|
||||
### **New Features**
|
||||
|
||||
- Added automation tests for the voting feature. [TidusJar]
|
||||
|
||||
- Update LidarrAvailabilityChecker.cs. [Jamie]
|
||||
|
||||
- Update CHANGELOG.md. [Jamie]
|
||||
|
||||
- Changes language selector to always show native language name. [Victor Usoltsev]
|
||||
|
||||
- Updated test dependancies. [TidusJar]
|
||||
|
||||
- Added in the external repo so we can rip out external stuff. [TidusJar]
|
||||
|
||||
- Added the ability to purge/remove issues. [TidusJar]
|
||||
|
||||
### **Fixes**
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (Swedish) [Jamie]
|
||||
|
||||
- New translations en.json (Spanish) [Jamie]
|
||||
|
||||
- New translations en.json (Portuguese, Brazilian) [Jamie]
|
||||
|
||||
- New translations en.json (Polish) [Jamie]
|
||||
|
||||
- New translations en.json (Norwegian) [Jamie]
|
||||
|
||||
- New translations en.json (Italian) [Jamie]
|
||||
|
||||
- New translations en.json (German) [Jamie]
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (Dutch) [Jamie]
|
||||
|
||||
- New translations en.json (Danish) [Jamie]
|
||||
|
||||
- When a users requests content and the voting is enabled, the user who requested is an automatic +1 vote. [TidusJar]
|
||||
|
||||
- Revert, no idea how this happened. [TidusJar]
|
||||
|
||||
- Fixed the build. Thanks Matt! [TidusJar]
|
||||
|
||||
- Fixes untickable mass email checkboxes in Safari. [Victor Usoltsev]
|
||||
|
||||
- [ImgBot] optimizes images. [ImgBotApp]
|
||||
|
||||
- Revert "Feature/purge issues" [Jamie]
|
||||
|
||||
- Fixed the issue where user preferences was not being inported into some notifications. [TidusJar]
|
||||
|
||||
- New role to enable users to remove their own requests. [Anojh]
|
||||
|
||||
- Users can now remove their own requests. [Anojh]
|
||||
|
||||
- New translations en.json (Danish) [Jamie]
|
||||
|
||||
- Fixed lidarr newsletter bug. [Jamie]
|
||||
|
||||
- Potentially fix the user profiles issue. [Jamie]
|
||||
|
||||
- Hides Radarr options on movie requests page if only 1 option available. [Victor Usoltsev]
|
||||
|
||||
- Hides Sonarr options on tv requests page if only 1 option available. [Victor Usoltsev]
|
||||
|
||||
- Fixed the issue where we could not delete users #2558. [TidusJar]
|
||||
|
||||
- New translations en.json (German) [Jamie]
|
||||
|
||||
- New translations en.json (Swedish) [Jamie]
|
||||
|
||||
- New translations en.json (Spanish) [Jamie]
|
||||
|
||||
- New translations en.json (Portuguese, Brazilian) [Jamie]
|
||||
|
||||
- New translations en.json (Polish) [Jamie]
|
||||
|
||||
- New translations en.json (Norwegian) [Jamie]
|
||||
|
||||
- New translations en.json (Italian) [Jamie]
|
||||
|
||||
- New translations en.json (German) [Jamie]
|
||||
|
||||
- New translations en.json (French) [Jamie]
|
||||
|
||||
- New translations en.json (Dutch) [Jamie]
|
||||
|
||||
- New translations en.json (Danish) [Jamie]
|
||||
|
||||
- Subscribe the user to the request when they vote on it. [TidusJar]
|
||||
|
||||
- Fixed #2555. [Jamie]
|
||||
|
||||
- Fixed #2549. [Jamie]
|
||||
|
||||
- Removed the pinID from the OAuth url #2548. [Jamie]
|
||||
|
||||
- Put the issue purge limit on the issues page. [Jamie]
|
||||
|
||||
- Date and times are now in the local users date time. [TidusJar]
|
||||
|
||||
- Fixed the migration. [TidusJar]
|
||||
|
||||
- ExternalContext migrations. [TidusJar]
|
||||
|
||||
- The settings have now been split out of the main db. [TidusJar]
|
||||
|
||||
- Search for the Lidarr Album when it's a new artist. [TidusJar]
|
||||
|
||||
- The album in Lidarr does not need to be marked as monitored for us to pick up it's available. Fixes #2536. [Jamie]
|
||||
|
||||
- Truncate the request title. [Jamie]
|
||||
|
||||
- Fixed #2535. [Jamie]
|
||||
|
||||
|
||||
## v3.0.3795 (2018-09-23)
|
||||
|
||||
### **New Features**
|
||||
|
||||
- Update CHANGELOG.md. [Jamie]
|
||||
|
||||
### **Fixes**
|
||||
|
||||
- Fixed the issue with notifications not sending. [Jamie]
|
||||
|
|
|
@ -3,10 +3,14 @@ configuration: Release
|
|||
os: Visual Studio 2017
|
||||
environment:
|
||||
nodejs_version: "9.8.0"
|
||||
typescript_version: "3.0.1"
|
||||
|
||||
install:
|
||||
# Get the latest stable version of Node.js or io.js
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
|
||||
- cmd: set path=%programfiles(x86)%\\Microsoft SDKs\TypeScript\3.0;%path%
|
||||
- cmd: tsc -v
|
||||
build_script:
|
||||
- ps: ./build.ps1 --settings_skipverification=true
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Ombi.Api.Notifications
|
|||
{
|
||||
return null;
|
||||
}
|
||||
var id = await _appConfig.Get(ConfigurationTypes.Notification);
|
||||
var id = await _appConfig.GetAsync(ConfigurationTypes.Notification);
|
||||
var request = new Request(string.Empty, ApiUrl, HttpMethod.Post);
|
||||
|
||||
var body = new OneSignalNotificationBody
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace Ombi.Api.Plex
|
|||
Task<PlexAccount> GetAccount(string authToken);
|
||||
Task<PlexMetadata> GetRecentlyAdded(string authToken, string uri, string sectionId);
|
||||
Task<OAuthPin> GetPin(int pinId);
|
||||
Task<Uri> GetOAuthUrl(int pinId, string code, string applicationUrl);
|
||||
Task<Uri> GetOAuthUrl(string code, string applicationUrl);
|
||||
Task<PlexAddWrapper> AddUser(string emailAddress, string serverId, string authToken, int[] libs);
|
||||
}
|
||||
}
|
|
@ -217,12 +217,11 @@ namespace Ombi.Api.Plex
|
|||
return await Api.Request<OAuthPin>(request);
|
||||
}
|
||||
|
||||
public async Task<Uri> GetOAuthUrl(int pinId, string code, string applicationUrl)
|
||||
public async Task<Uri> GetOAuthUrl(string code, string applicationUrl)
|
||||
{
|
||||
var request = new Request("auth#", "https://app.plex.tv", HttpMethod.Get);
|
||||
await AddHeaders(request);
|
||||
|
||||
request.AddQueryString("pinID", pinId.ToString());
|
||||
request.AddQueryString("code", code);
|
||||
request.AddQueryString("context[device][product]", ApplicationName);
|
||||
request.AddQueryString("context[device][environment]", "bundled");
|
||||
|
|
73
src/Ombi.Core.Tests/Engine/VoteEngineTests.cs
Normal file
73
src/Ombi.Core.Tests/Engine/VoteEngineTests.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Threading.Tasks;
|
||||
using AutoFixture;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Engine;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Core.Tests.Engine
|
||||
{
|
||||
[TestFixture]
|
||||
public class VoteEngineTests
|
||||
{
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
F = new Fixture();
|
||||
VoteRepository = new Mock<IRepository<Votes>>();
|
||||
VoteSettings = new Mock<ISettingsService<VoteSettings>>();
|
||||
MusicRequestEngine = new Mock<IMusicRequestEngine>();
|
||||
TvRequestEngine = new Mock<ITvRequestEngine>();
|
||||
MovieRequestEngine = new Mock<IMovieRequestEngine>();
|
||||
MovieRequestEngine = new Mock<IMovieRequestEngine>();
|
||||
User = new Mock<IPrincipal>();
|
||||
UserManager = new Mock<OmbiUserManager>();
|
||||
UserManager.Setup(x => x.Users)
|
||||
.Returns(new EnumerableQuery<OmbiUser>(new List<OmbiUser> {new OmbiUser {Id = "abc"}}));
|
||||
Rule = new Mock<IRuleEvaluator>();
|
||||
Engine = new VoteEngine(VoteRepository.Object, User.Object, UserManager.Object, Rule.Object, VoteSettings.Object, MusicRequestEngine.Object,
|
||||
TvRequestEngine.Object, MovieRequestEngine.Object);
|
||||
}
|
||||
|
||||
public Fixture F { get; set; }
|
||||
public VoteEngine Engine { get; set; }
|
||||
public Mock<IPrincipal> User { get; set; }
|
||||
public Mock<OmbiUserManager> UserManager { get; set; }
|
||||
public Mock<IRuleEvaluator> Rule { get; set; }
|
||||
public Mock<IRepository<Votes>> VoteRepository { get; set; }
|
||||
public Mock<ISettingsService<VoteSettings>> VoteSettings { get; set; }
|
||||
public Mock<IMusicRequestEngine> MusicRequestEngine { get; set; }
|
||||
public Mock<ITvRequestEngine> TvRequestEngine { get; set; }
|
||||
public Mock<IMovieRequestEngine> MovieRequestEngine { get; set; }
|
||||
|
||||
[Test]
|
||||
[Ignore("Need to mock the user manager")]
|
||||
public async Task New_Upvote()
|
||||
{
|
||||
VoteSettings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new VoteSettings());
|
||||
var votes = F.CreateMany<Votes>().ToList();
|
||||
votes.Add(new Votes
|
||||
{
|
||||
RequestId = 1,
|
||||
RequestType = RequestType.Movie,
|
||||
UserId = "abc"
|
||||
});
|
||||
VoteRepository.Setup(x => x.GetAll()).Returns(new EnumerableQuery<Votes>(votes));
|
||||
var result = await Engine.UpVote(1, RequestType.Movie);
|
||||
|
||||
Assert.That(result.Result, Is.True);
|
||||
VoteRepository.Verify(x => x.Add(It.Is<Votes>(c => c.UserId == "abc" && c.VoteType == VoteType.Upvote)), Times.Once);
|
||||
VoteRepository.Verify(x => x.Delete(It.IsAny<Votes>()), Times.Once);
|
||||
MovieRequestEngine.Verify(x => x.ApproveMovieById(1), Times.Never);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,9 +5,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Moq" Version="4.9.0" />
|
||||
<PackageReference Include="AutoFixture" Version="4.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="Nunit" Version="3.10.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.8.0" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -36,17 +36,17 @@ namespace Ombi.Core.Authentication
|
|||
return await _api.GetAccount(accessToken);
|
||||
}
|
||||
|
||||
public async Task<Uri> GetOAuthUrl(int pinId, string code, string websiteAddress = null)
|
||||
public async Task<Uri> GetOAuthUrl(string code, string websiteAddress = null)
|
||||
{
|
||||
var settings = await _customizationSettingsService.GetSettingsAsync();
|
||||
var url = await _api.GetOAuthUrl(pinId, code, settings.ApplicationUrl.IsNullOrEmpty() ? websiteAddress : settings.ApplicationUrl);
|
||||
var url = await _api.GetOAuthUrl(code, settings.ApplicationUrl.IsNullOrEmpty() ? websiteAddress : settings.ApplicationUrl);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
public async Task<Uri> GetWizardOAuthUrl(int pinId, string code, string websiteAddress)
|
||||
public async Task<Uri> GetWizardOAuthUrl(string code, string websiteAddress)
|
||||
{
|
||||
var url = await _api.GetOAuthUrl(pinId, code, websiteAddress);
|
||||
var url = await _api.GetOAuthUrl(code, websiteAddress);
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
|
19
src/Ombi.Core/Engine/IVoteEngine.cs
Normal file
19
src/Ombi.Core/Engine/IVoteEngine.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Core.Models;
|
||||
using Ombi.Core.Models.UI;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
public interface IVoteEngine
|
||||
{
|
||||
Task<VoteEngineResult> DownVote(int requestId, RequestType requestType);
|
||||
Task<Votes> GetVoteForUser(int requestId, string userId);
|
||||
IQueryable<Votes> GetVotes(int requestId, RequestType requestType);
|
||||
Task RemoveCurrentVote(Votes currentVote);
|
||||
Task<VoteEngineResult> UpVote(int requestId, RequestType requestType);
|
||||
Task<List<VoteViewModel>> GetMovieViewModel();
|
||||
}
|
||||
}
|
|
@ -7,11 +7,8 @@ using Ombi.Core.Models.Search;
|
|||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Entities;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Helpers;
|
||||
|
||||
namespace Ombi.Core.Engine.Interfaces
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Ombi.Core.Engine.Interfaces
|
|||
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);
|
||||
|
||||
Task RemoveMovieRequest(int requestId);
|
||||
Task RemoveAllMovieRequests();
|
||||
|
||||
Task<MovieRequests> UpdateMovieRequest(MovieRequests request);
|
||||
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
|
||||
|
|
|
@ -416,6 +416,12 @@ namespace Ombi.Core.Engine
|
|||
await MovieRepository.Delete(request);
|
||||
}
|
||||
|
||||
public async Task RemoveAllMovieRequests()
|
||||
{
|
||||
var request = MovieRepository.GetAll();
|
||||
await MovieRepository.DeleteRange(request);
|
||||
}
|
||||
|
||||
public async Task<bool> UserHasRequest(string userId)
|
||||
{
|
||||
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
|
||||
|
@ -483,7 +489,7 @@ namespace Ombi.Core.Engine
|
|||
RequestType = RequestType.Movie,
|
||||
});
|
||||
|
||||
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!"};
|
||||
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!", RequestId = model.Id};
|
||||
}
|
||||
|
||||
public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
|
||||
|
|
|
@ -495,7 +495,7 @@ namespace Ombi.Core.Engine
|
|||
RequestType = RequestType.Album,
|
||||
});
|
||||
|
||||
return new RequestEngineResult { Result = true, Message = $"{model.Title} has been successfully added!" };
|
||||
return new RequestEngineResult { Result = true, Message = $"{model.Title} has been successfully added!", RequestId = model.Id };
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
public string Message { get; set; }
|
||||
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
|
||||
public string ErrorMessage { get; set; }
|
||||
public int RequestId { get; set; }
|
||||
}
|
||||
}
|
|
@ -604,15 +604,16 @@ namespace Ombi.Core.Engine
|
|||
var result = await TvSender.Send(model);
|
||||
if (result.Success)
|
||||
{
|
||||
return new RequestEngineResult { Result = true };
|
||||
return new RequestEngineResult { Result = true, RequestId = model.Id};
|
||||
}
|
||||
return new RequestEngineResult
|
||||
{
|
||||
ErrorMessage = result.Message
|
||||
ErrorMessage = result.Message,
|
||||
RequestId = model.Id
|
||||
};
|
||||
}
|
||||
|
||||
return new RequestEngineResult { Result = true };
|
||||
return new RequestEngineResult { Result = true, RequestId = model.Id };
|
||||
}
|
||||
|
||||
public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
continue;
|
||||
}
|
||||
retVal.Add(await ProcessResult(tvMazeSearch));
|
||||
retVal.Add(ProcessResult(tvMazeSearch));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ namespace Ombi.Core.Engine
|
|||
public async Task<IEnumerable<SearchTvShowViewModel>> Popular()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.PopularTv, async () => await TraktApi.GetPopularShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
|
@ -131,35 +131,35 @@ namespace Ombi.Core.Engine
|
|||
{
|
||||
|
||||
var result = await Cache.GetOrAdd(CacheKeys.AnticipatedTv, async () => await TraktApi.GetAnticipatedShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> MostWatches()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.MostWatchesTv, async () => await TraktApi.GetMostWatchesShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SearchTvShowViewModel>> Trending()
|
||||
{
|
||||
var result = await Cache.GetOrAdd(CacheKeys.TrendingTv, async () => await TraktApi.GetTrendingShows(), DateTime.Now.AddHours(12));
|
||||
var processed = await ProcessResults(result);
|
||||
var processed = ProcessResults(result);
|
||||
return processed;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<SearchTvShowViewModel>> ProcessResults<T>(IEnumerable<T> items)
|
||||
private IEnumerable<SearchTvShowViewModel> ProcessResults<T>(IEnumerable<T> items)
|
||||
{
|
||||
var retVal = new List<SearchTvShowViewModel>();
|
||||
foreach (var tvMazeSearch in items)
|
||||
{
|
||||
retVal.Add(await ProcessResult(tvMazeSearch));
|
||||
retVal.Add(ProcessResult(tvMazeSearch));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private async Task<SearchTvShowViewModel> ProcessResult<T>(T tvMazeSearch)
|
||||
private SearchTvShowViewModel ProcessResult<T>(T tvMazeSearch)
|
||||
{
|
||||
return Mapper.Map<SearchTvShowViewModel>(tvMazeSearch);
|
||||
}
|
||||
|
|
263
src/Ombi.Core/Engine/VoteEngine.cs
Normal file
263
src/Ombi.Core/Engine/VoteEngine.cs
Normal file
|
@ -0,0 +1,263 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Core.Authentication;
|
||||
using Ombi.Core.Engine.Interfaces;
|
||||
using Ombi.Core.Models;
|
||||
using Ombi.Core.Models.UI;
|
||||
using Ombi.Core.Rule.Interfaces;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Schedule.Jobs.Ombi;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Core.Engine
|
||||
{
|
||||
public class VoteEngine : BaseEngine, IVoteEngine
|
||||
{
|
||||
public VoteEngine(IRepository<Votes> votes, IPrincipal user, OmbiUserManager um, IRuleEvaluator r, ISettingsService<VoteSettings> voteSettings,
|
||||
IMusicRequestEngine musicRequestEngine, ITvRequestEngine tvRequestEngine, IMovieRequestEngine movieRequestEngine) : base(user, um, r)
|
||||
{
|
||||
_voteRepository = votes;
|
||||
_voteSettings = voteSettings;
|
||||
_movieRequestEngine = movieRequestEngine;
|
||||
_musicRequestEngine = musicRequestEngine;
|
||||
_tvRequestEngine = tvRequestEngine;
|
||||
}
|
||||
|
||||
private readonly IRepository<Votes> _voteRepository;
|
||||
private readonly ISettingsService<VoteSettings> _voteSettings;
|
||||
private readonly IMusicRequestEngine _musicRequestEngine;
|
||||
private readonly ITvRequestEngine _tvRequestEngine;
|
||||
private readonly IMovieRequestEngine _movieRequestEngine;
|
||||
|
||||
public async Task<List<VoteViewModel>> GetMovieViewModel()
|
||||
{
|
||||
var vm = new List<VoteViewModel>();
|
||||
var movieRequests = await _movieRequestEngine.GetRequests();
|
||||
var tvRequestsTask = _tvRequestEngine.GetRequests();
|
||||
var musicRequestsTask = _musicRequestEngine.GetRequests();
|
||||
var user = await GetUser();
|
||||
foreach (var r in movieRequests)
|
||||
{
|
||||
if (r.Available || r.Approved || (r.Denied ?? false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Make model
|
||||
var votes = GetVotes(r.Id, RequestType.Movie);
|
||||
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
||||
var myVote = await votes.FirstOrDefaultAsync(x => x.UserId == user.Id && !x.Deleted);
|
||||
|
||||
vm.Add(new VoteViewModel
|
||||
{
|
||||
Upvotes = upVotes,
|
||||
Downvotes = downVotes,
|
||||
RequestId = r.Id,
|
||||
RequestType = RequestType.Movie,
|
||||
Title = r.Title,
|
||||
Image = $"https://image.tmdb.org/t/p/w500/{r.PosterPath}",
|
||||
Background = $"https://image.tmdb.org/t/p/w1280{r.Background}",
|
||||
Description = r.Overview,
|
||||
AlreadyVoted = myVote != null,
|
||||
MyVote = myVote?.VoteType ?? VoteType.Downvote
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var r in await musicRequestsTask)
|
||||
{
|
||||
if (r.Available || r.Approved || (r.Denied ?? false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Make model
|
||||
var votes = GetVotes(r.Id, RequestType.Album);
|
||||
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
||||
var myVote = await votes.FirstOrDefaultAsync(x => x.UserId == user.Id && !x.Deleted);
|
||||
vm.Add(new VoteViewModel
|
||||
{
|
||||
Upvotes = upVotes,
|
||||
Downvotes = downVotes,
|
||||
RequestId = r.Id,
|
||||
RequestType = RequestType.Album,
|
||||
Title = r.Title,
|
||||
Image = r.Cover,
|
||||
Background = r.Cover,
|
||||
Description = r.ArtistName,
|
||||
AlreadyVoted = myVote != null,
|
||||
MyVote = myVote?.VoteType ?? VoteType.Downvote
|
||||
});
|
||||
}
|
||||
|
||||
foreach (var r in await tvRequestsTask)
|
||||
{
|
||||
|
||||
foreach (var childRequests in r.ChildRequests)
|
||||
{
|
||||
var finalsb = new StringBuilder();
|
||||
if (childRequests.Available || childRequests.Approved || (childRequests.Denied ?? false))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var votes = GetVotes(childRequests.Id, RequestType.TvShow);
|
||||
// Make model
|
||||
var upVotes = await votes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||
var downVotes = await votes.Where(x => x.VoteType == VoteType.Downvote).CountAsync();
|
||||
var myVote = await votes.FirstOrDefaultAsync(x => x.UserId == user.Id && !x.Deleted);
|
||||
foreach (var epInformation in childRequests.SeasonRequests.OrderBy(x => x.SeasonNumber))
|
||||
{
|
||||
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
|
||||
var episodeString = NewsletterJob.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
|
||||
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}");
|
||||
finalsb.Append("<br />");
|
||||
}
|
||||
vm.Add(new VoteViewModel
|
||||
{
|
||||
Upvotes = upVotes,
|
||||
Downvotes = downVotes,
|
||||
RequestId = childRequests.Id,
|
||||
RequestType = RequestType.TvShow,
|
||||
Title = r.Title,
|
||||
Image = r.PosterPath,
|
||||
Background = r.Background,
|
||||
Description = finalsb.ToString(),
|
||||
AlreadyVoted = myVote != null,
|
||||
MyVote = myVote?.VoteType ?? VoteType.Downvote
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
public IQueryable<Votes> GetVotes(int requestId, RequestType requestType)
|
||||
{
|
||||
return _voteRepository.GetAll().Where(x => x.RequestType == requestType && requestId == x.RequestId);
|
||||
}
|
||||
|
||||
public Task<Votes> GetVoteForUser(int requestId, string userId)
|
||||
{
|
||||
return _voteRepository.GetAll().FirstOrDefaultAsync(x => x.RequestId == requestId && x.UserId == userId);
|
||||
}
|
||||
|
||||
public async Task<VoteEngineResult> UpVote(int requestId, RequestType requestType)
|
||||
{
|
||||
var voteSettings = await _voteSettings.GetSettingsAsync();
|
||||
if (!voteSettings.Enabled)
|
||||
{
|
||||
return new VoteEngineResult {Result = true};
|
||||
}
|
||||
// How many votes does this have?!
|
||||
var currentVotes = GetVotes(requestId, requestType);
|
||||
|
||||
var user = await GetUser();
|
||||
|
||||
// Does this user have a downvote? If so we should revert it and make it an upvote
|
||||
var currentVote = await GetVoteForUser(requestId, user.Id);
|
||||
if (currentVote != null && currentVote.VoteType == VoteType.Upvote)
|
||||
{
|
||||
return new VoteEngineResult { ErrorMessage = "You have already voted!" };
|
||||
}
|
||||
await RemoveCurrentVote(currentVote);
|
||||
await _movieRequestEngine.SubscribeToRequest(requestId, requestType);
|
||||
|
||||
await _voteRepository.Add(new Votes
|
||||
{
|
||||
Date = DateTime.UtcNow,
|
||||
RequestId = requestId,
|
||||
RequestType = requestType,
|
||||
UserId = user.Id,
|
||||
VoteType = VoteType.Upvote
|
||||
});
|
||||
|
||||
var upVotes = await currentVotes.Where(x => x.VoteType == VoteType.Upvote).CountAsync();
|
||||
var downVotes = -(await currentVotes.Where(x => x.VoteType == VoteType.Downvote).CountAsync());
|
||||
|
||||
var totalVotes = upVotes + downVotes;
|
||||
RequestEngineResult result = null;
|
||||
switch (requestType)
|
||||
{
|
||||
case RequestType.TvShow:
|
||||
if (totalVotes >= voteSettings.TvShowVoteMax)
|
||||
{
|
||||
result = await _tvRequestEngine.ApproveChildRequest(requestId);
|
||||
}
|
||||
break;
|
||||
case RequestType.Movie:
|
||||
if (totalVotes >= voteSettings.MovieVoteMax)
|
||||
{
|
||||
result = await _movieRequestEngine.ApproveMovieById(requestId);
|
||||
}
|
||||
break;
|
||||
case RequestType.Album:
|
||||
if (totalVotes >= voteSettings.MusicVoteMax)
|
||||
{
|
||||
result = await _musicRequestEngine.ApproveAlbumById(requestId);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(requestType), requestType, null);
|
||||
}
|
||||
|
||||
if (result != null && !result.Result)
|
||||
{
|
||||
return new VoteEngineResult
|
||||
{
|
||||
ErrorMessage = "Voted succesfully but could not approve!"
|
||||
};
|
||||
}
|
||||
|
||||
return new VoteEngineResult
|
||||
{
|
||||
Result = true
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<VoteEngineResult> DownVote(int requestId, RequestType requestType)
|
||||
{
|
||||
var voteSettings = await _voteSettings.GetSettingsAsync();
|
||||
if (!voteSettings.Enabled)
|
||||
{
|
||||
return new VoteEngineResult { Result = true };
|
||||
}
|
||||
var user = await GetUser();
|
||||
var currentVote = await GetVoteForUser(requestId, user.Id);
|
||||
if (currentVote != null && currentVote.VoteType == VoteType.Downvote)
|
||||
{
|
||||
return new VoteEngineResult { ErrorMessage = "You have already voted!" };
|
||||
}
|
||||
await RemoveCurrentVote(currentVote);
|
||||
|
||||
await _movieRequestEngine.UnSubscribeRequest(requestId, requestType);
|
||||
|
||||
await _voteRepository.Add(new Votes
|
||||
{
|
||||
Date = DateTime.UtcNow,
|
||||
RequestId = requestId,
|
||||
RequestType = requestType,
|
||||
UserId = user.Id,
|
||||
VoteType = VoteType.Downvote
|
||||
});
|
||||
|
||||
return new VoteEngineResult
|
||||
{
|
||||
Result = true
|
||||
};
|
||||
}
|
||||
|
||||
public async Task RemoveCurrentVote(Votes currentVote)
|
||||
{
|
||||
if (currentVote != null)
|
||||
{
|
||||
await _voteRepository.Delete(currentVote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,8 +7,8 @@ namespace Ombi.Core.Authentication
|
|||
public interface IPlexOAuthManager
|
||||
{
|
||||
Task<string> GetAccessTokenFromPin(int pinId);
|
||||
Task<Uri> GetOAuthUrl(int pinId, string code, string websiteAddress = null);
|
||||
Task<Uri> GetWizardOAuthUrl(int pinId, string code, string websiteAddress);
|
||||
Task<Uri> GetOAuthUrl(string code, string websiteAddress = null);
|
||||
Task<Uri> GetWizardOAuthUrl(string code, string websiteAddress);
|
||||
Task<PlexAccount> GetAccount(string accessToken);
|
||||
}
|
||||
}
|
18
src/Ombi.Core/Models/UI/VoteViewModel.cs
Normal file
18
src/Ombi.Core/Models/UI/VoteViewModel.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Core.Models.UI
|
||||
{
|
||||
public class VoteViewModel
|
||||
{
|
||||
public int RequestId { get; set; }
|
||||
public RequestType RequestType { get; set; }
|
||||
public string Image { get; set; }
|
||||
public string Background { get; set; }
|
||||
public int Upvotes { get; set; }
|
||||
public int Downvotes { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool AlreadyVoted { get; set; }
|
||||
public VoteType MyVote { get; set; }
|
||||
}
|
||||
}
|
10
src/Ombi.Core/Models/VoteEngineResult.cs
Normal file
10
src/Ombi.Core/Models/VoteEngineResult.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace Ombi.Core.Models
|
||||
{
|
||||
public class VoteEngineResult
|
||||
{
|
||||
public bool Result { get; set; }
|
||||
public string Message { get; set; }
|
||||
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
}
|
|
@ -7,12 +7,12 @@ namespace Ombi.Core.Rule.Rules.Request
|
|||
{
|
||||
public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest>
|
||||
{
|
||||
public SonarrCacheRequestRule(IOmbiContext ctx)
|
||||
public SonarrCacheRequestRule(IExternalContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public Task<RuleResult> Execute(BaseRequest obj)
|
||||
{
|
||||
|
|
|
@ -34,12 +34,12 @@ namespace Ombi.Core.Rule.Rules.Search
|
|||
{
|
||||
public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel>
|
||||
{
|
||||
public SonarrCacheSearchRule(IOmbiContext ctx)
|
||||
public SonarrCacheSearchRule(IExternalContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public Task<RuleResult> Execute(SearchViewModel obj)
|
||||
{
|
||||
|
|
|
@ -10,12 +10,12 @@ namespace Ombi.Core.Rule.Rules
|
|||
{
|
||||
public class SonarrCacheRule
|
||||
{
|
||||
public SonarrCacheRule(IOmbiContext ctx)
|
||||
public SonarrCacheRule(IExternalContext ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
}
|
||||
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public async Task<RuleResult> Execute(BaseRequest obj)
|
||||
{
|
||||
|
|
|
@ -76,7 +76,35 @@ namespace Ombi.Core.Senders
|
|||
var result = await _lidarrApi.AddArtist(newArtist, settings.ApiKey, settings.FullUri);
|
||||
if (result != null && result.id > 0)
|
||||
{
|
||||
// Setup the albums
|
||||
// Search for it
|
||||
if (!settings.AddOnly)
|
||||
{
|
||||
// get the album
|
||||
var album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
|
||||
|
||||
var albumToSearch = album.FirstOrDefault(x =>
|
||||
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
||||
var maxRetryCount = 10; // 5 seconds
|
||||
var currentRetry = 0;
|
||||
while (albumToSearch != null)
|
||||
{
|
||||
if (currentRetry >= maxRetryCount)
|
||||
{
|
||||
break;
|
||||
}
|
||||
currentRetry++;
|
||||
await Task.Delay(500);
|
||||
album = await _lidarrApi.GetAllAlbumsByArtistId(result.id, settings.ApiKey, settings.FullUri);
|
||||
albumToSearch = album.FirstOrDefault(x =>
|
||||
x.foreignAlbumId.Equals(model.ForeignAlbumId, StringComparison.InvariantCultureIgnoreCase));
|
||||
}
|
||||
|
||||
|
||||
if (albumToSearch != null)
|
||||
{
|
||||
await _lidarrApi.AlbumSearch(new[] {albumToSearch.id}, settings.ApiKey, settings.FullUri);
|
||||
}
|
||||
}
|
||||
return new SenderResult { Message = "Album has been requested!", Sent = true, Success = true };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<IMusicSender, MusicSender>();
|
||||
services.AddTransient<IMassEmailSender, MassEmailSender>();
|
||||
services.AddTransient<IPlexOAuthManager, PlexOAuthManager>();
|
||||
services.AddTransient<IVoteEngine, VoteEngine>();
|
||||
}
|
||||
public static void RegisterHttp(this IServiceCollection services)
|
||||
{
|
||||
|
@ -128,8 +129,12 @@ namespace Ombi.DependencyInjection
|
|||
|
||||
public static void RegisterStore(this IServiceCollection services) {
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<OmbiContext>();
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<SettingsContext>();
|
||||
services.AddEntityFrameworkSqlite().AddDbContext<ExternalContext>();
|
||||
|
||||
services.AddScoped<IOmbiContext, OmbiContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||
services.AddScoped<ISettingsContext, SettingsContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||
services.AddScoped<IExternalContext, ExternalContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
|
||||
services.AddTransient<ISettingsRepository, SettingsJsonRepository>();
|
||||
services.AddTransient<ISettingsResolver, SettingsResolver>();
|
||||
services.AddTransient<IPlexContentRepository, PlexServerContentRepository>();
|
||||
|
@ -144,6 +149,7 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<ITokenRepository, TokenRepository>();
|
||||
services.AddTransient(typeof(ISettingsService<>), typeof(SettingsService<>));
|
||||
services.AddTransient(typeof(IRepository<>), typeof(Repository<>));
|
||||
services.AddTransient(typeof(IExternalRepository<>), typeof(ExternalRepository<>));
|
||||
}
|
||||
public static void RegisterServices(this IServiceCollection services)
|
||||
{
|
||||
|
@ -191,6 +197,7 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<ILidarrAlbumSync, LidarrAlbumSync>();
|
||||
services.AddTransient<ILidarrArtistSync, LidarrArtistSync>();
|
||||
services.AddTransient<ILidarrAvailabilityChecker, LidarrAvailabilityChecker>();
|
||||
services.AddTransient<IIssuesPurge, IssuesPurge>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,5 +14,6 @@
|
|||
public const string RequestMusic = nameof(RequestMusic);
|
||||
public const string Disabled = nameof(Disabled);
|
||||
public const string ReceivesNewsletter = nameof(ReceivesNewsletter);
|
||||
public const string ManageOwnRequests = nameof(ManageOwnRequests);
|
||||
}
|
||||
}
|
|
@ -5,11 +5,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nunit" Version="3.8.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
|
||||
<PackageReference Include="Nunit" Version="3.10.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
|
||||
<PackageReference Include="Moq" Version="4.7.99" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -170,6 +170,24 @@ namespace Ombi.Notifications.Interfaces
|
|||
{
|
||||
return new NotificationMessageContent { Disabled = true };
|
||||
}
|
||||
|
||||
if (model.UserId.IsNullOrEmpty())
|
||||
{
|
||||
if (model.RequestType == RequestType.Movie)
|
||||
{
|
||||
model.UserId = MovieRequest.RequestedUserId;
|
||||
}
|
||||
|
||||
if (model.RequestType == RequestType.Album)
|
||||
{
|
||||
model.UserId = AlbumRequest.RequestedUserId;
|
||||
}
|
||||
|
||||
if (model.RequestType == RequestType.TvShow)
|
||||
{
|
||||
model.UserId = TvRequest.RequestedUserId;
|
||||
}
|
||||
}
|
||||
var parsed = Parse(model, template, agent);
|
||||
|
||||
return parsed;
|
||||
|
@ -184,7 +202,7 @@ namespace Ombi.Notifications.Interfaces
|
|||
protected UserNotificationPreferences GetUserPreference(string userId, NotificationAgent agent)
|
||||
{
|
||||
return UserNotificationPreferences.GetAll()
|
||||
.FirstOrDefault(x => x.Enabled && x.Agent == agent && x.UserId == userId);
|
||||
.FirstOrDefault(x => x.Agent == agent && x.UserId == userId);
|
||||
}
|
||||
|
||||
private NotificationMessageContent Parse(NotificationOptions model, NotificationTemplates template, NotificationAgent agent)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Ombi.Notifications
|
|||
LoadIssues(opts);
|
||||
if (pref != null)
|
||||
{
|
||||
UserPreference = pref.Enabled ? pref.Value : string.Empty;
|
||||
UserPreference = pref.Value;
|
||||
}
|
||||
|
||||
string title;
|
||||
|
@ -268,6 +268,7 @@ namespace Ombi.Notifications
|
|||
{nameof(IssueUser),IssueUser},
|
||||
{nameof(UserName),UserName},
|
||||
{nameof(Alias),Alias},
|
||||
{nameof(UserPreference),UserPreference},
|
||||
};
|
||||
}
|
||||
}
|
85
src/Ombi.Schedule.Tests/IssuesPurgeTests.cs
Normal file
85
src/Ombi.Schedule.Tests/IssuesPurgeTests.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Schedule.Jobs.Ombi;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Schedule.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class IssuesPurgeTests
|
||||
{
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Repo = new Mock<IRepository<Issues>>();
|
||||
Settings = new Mock<ISettingsService<IssueSettings>>();
|
||||
Settings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new IssueSettings());
|
||||
Job = new IssuesPurge(Repo.Object, Settings.Object);
|
||||
}
|
||||
|
||||
public Mock<IRepository<Issues>> Repo { get; set; }
|
||||
public Mock<ISettingsService<IssueSettings>> Settings { get; set; }
|
||||
public IssuesPurge Job { get; set; }
|
||||
|
||||
[Test]
|
||||
public async Task DoesNotRun_WhenDisabled()
|
||||
{
|
||||
await Job.Start();
|
||||
Repo.Verify(x => x.GetAll(),Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Deletes_Correct_Issue()
|
||||
{
|
||||
var issues = new List<Issues>()
|
||||
{
|
||||
new Issues
|
||||
{
|
||||
Status = IssueStatus.Resolved,
|
||||
ResovledDate = DateTime.Now.AddDays(-5).AddHours(-1)
|
||||
}
|
||||
};
|
||||
|
||||
Settings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new IssueSettings { DeleteIssues = true, DaysAfterResolvedToDelete = 5 });
|
||||
Repo.Setup(x => x.GetAll()).Returns(new EnumerableQuery<Issues>(issues));
|
||||
await Job.Start();
|
||||
|
||||
Assert.That(issues.First().Status, Is.EqualTo(IssueStatus.Deleted));
|
||||
Repo.Verify(x => x.SaveChangesAsync(), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task DoesNot_Delete_AnyIssues()
|
||||
{
|
||||
var issues = new List<Issues>()
|
||||
{
|
||||
new Issues
|
||||
{
|
||||
Status = IssueStatus.Resolved,
|
||||
ResovledDate = DateTime.Now.AddDays(-2)
|
||||
},
|
||||
new Issues
|
||||
{
|
||||
Status = IssueStatus.Resolved,
|
||||
ResovledDate = DateTime.Now.AddDays(-6)
|
||||
}
|
||||
};
|
||||
|
||||
Settings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new IssueSettings { DeleteIssues = true, DaysAfterResolvedToDelete = 5 });
|
||||
Repo.Setup(x => x.GetAll()).Returns(new EnumerableQuery<Issues>(issues));
|
||||
await Job.Start();
|
||||
|
||||
Assert.That(issues[0].Status, Is.Not.EqualTo(IssueStatus.Deleted));
|
||||
Assert.That(issues[1].Status, Is.EqualTo(IssueStatus.Deleted));
|
||||
Repo.Verify(x => x.SaveChangesAsync(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Schedule.Jobs.Ombi;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Settings.Settings.Models.Notifications;
|
||||
using Ombi.Store.Entities;
|
||||
using static Ombi.Schedule.Jobs.Ombi.NewsletterJob;
|
||||
|
||||
namespace Ombi.Schedule.Tests
|
||||
{
|
||||
|
@ -15,17 +10,12 @@ namespace Ombi.Schedule.Tests
|
|||
[TestCaseSource(nameof(EpisodeListData))]
|
||||
public string BuildEpisodeListTest(List<int> episodes)
|
||||
{
|
||||
var emailSettings = new Mock<ISettingsService<EmailNotificationSettings>>();
|
||||
var customziation = new Mock<ISettingsService<CustomizationSettings>>();
|
||||
var newsletterSettings = new Mock<ISettingsService<NewsletterSettings>>();
|
||||
var newsletter = new NewsletterJob(null, null, null, null, null, null, customziation.Object, emailSettings.Object, null, null, newsletterSettings.Object, null, null, null, null);
|
||||
|
||||
var ep = new List<int>();
|
||||
foreach (var i in episodes)
|
||||
{
|
||||
ep.Add(i);
|
||||
}
|
||||
var result = newsletter.BuildEpisodeList(ep);
|
||||
var result = BuildEpisodeList(ep);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.3" />
|
||||
<PackageReference Include="Moq" Version="4.7.99" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="Nunit" Version="3.10.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.8.0" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -20,7 +20,8 @@ namespace Ombi.Schedule
|
|||
IOmbiAutomaticUpdater updater, IEmbyContentSync embySync, IPlexUserImporter userImporter,
|
||||
IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache,
|
||||
ISettingsService<JobSettings> jobsettings, ISickRageSync srSync, IRefreshMetadata refresh,
|
||||
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist)
|
||||
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist,
|
||||
IIssuesPurge purge)
|
||||
{
|
||||
_plexContentSync = plexContentSync;
|
||||
_radarrSync = radarrSync;
|
||||
|
@ -36,6 +37,7 @@ namespace Ombi.Schedule
|
|||
_newsletter = newsletter;
|
||||
_plexRecentlyAddedSync = recentlyAddedPlex;
|
||||
_lidarrArtistSync = artist;
|
||||
_issuesPurge = purge;
|
||||
}
|
||||
|
||||
private readonly IPlexContentSync _plexContentSync;
|
||||
|
@ -52,6 +54,7 @@ namespace Ombi.Schedule
|
|||
private readonly IRefreshMetadata _refreshMetadata;
|
||||
private readonly INewsletterJob _newsletter;
|
||||
private readonly ILidarrArtistSync _lidarrArtistSync;
|
||||
private readonly IIssuesPurge _issuesPurge;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
|
@ -66,6 +69,7 @@ namespace Ombi.Schedule
|
|||
RecurringJob.AddOrUpdate(() => _srSync.Start(), JobSettingsHelper.SickRageSync(s));
|
||||
RecurringJob.AddOrUpdate(() => _refreshMetadata.Start(), JobSettingsHelper.RefreshMetadata(s));
|
||||
RecurringJob.AddOrUpdate(() => _lidarrArtistSync.CacheContent(), JobSettingsHelper.LidarrArtistSync(s));
|
||||
RecurringJob.AddOrUpdate(() => _issuesPurge.Start(), JobSettingsHelper.IssuePurge(s));
|
||||
|
||||
RecurringJob.AddOrUpdate(() => _updater.Update(null), JobSettingsHelper.Updater(s));
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
public class CouchPotatoSync : ICouchPotatoSync
|
||||
{
|
||||
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
|
||||
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IOmbiContext ctx)
|
||||
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx)
|
||||
{
|
||||
_settings = cpSettings;
|
||||
_api = api;
|
||||
|
@ -54,7 +54,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
|
|||
private readonly ISettingsService<CouchPotatoSettings> _settings;
|
||||
private readonly ICouchPotatoApi _api;
|
||||
private readonly ILogger<CouchPotatoSync> _log;
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
{
|
||||
public class LidarrAlbumSync : ILidarrAlbumSync
|
||||
{
|
||||
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IOmbiContext ctx,
|
||||
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IExternalContext ctx,
|
||||
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
|
||||
{
|
||||
_lidarrSettings = lidarr;
|
||||
|
@ -35,7 +35,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
private readonly ILidarrApi _lidarrApi;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
private readonly IBackgroundJobClient _job;
|
||||
private readonly ILidarrAvailabilityChecker _availability;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
{
|
||||
public class LidarrArtistSync : ILidarrArtistSync
|
||||
{
|
||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IOmbiContext ctx,
|
||||
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx,
|
||||
IBackgroundJobClient background, ILidarrAlbumSync album)
|
||||
{
|
||||
_lidarrSettings = lidarr;
|
||||
|
@ -35,7 +35,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
private readonly ISettingsService<LidarrSettings> _lidarrSettings;
|
||||
private readonly ILidarrApi _lidarrApi;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
private readonly IBackgroundJobClient _job;
|
||||
private readonly ILidarrAlbumSync _albumSync;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
|
|||
var cachedAlbum = await _cachedAlbums.FirstOrDefaultAsync(x => x.ForeignAlbumId.Equals(request.ForeignAlbumId));
|
||||
if (cachedAlbum != null)
|
||||
{
|
||||
if (cachedAlbum.Monitored && cachedAlbum.FullyAvailable)
|
||||
if (cachedAlbum.FullyAvailable)
|
||||
{
|
||||
request.Available = true;
|
||||
request.MarkedAsAvailable = DateTime.Now;
|
||||
|
|
9
src/Ombi.Schedule/Jobs/Ombi/IIssuesPurge.cs
Normal file
9
src/Ombi.Schedule/Jobs/Ombi/IIssuesPurge.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Ombi
|
||||
{
|
||||
public interface IIssuesPurge : IBaseJob
|
||||
{
|
||||
Task Start();
|
||||
}
|
||||
}
|
63
src/Ombi.Schedule/Jobs/Ombi/IssuesPurge.cs
Normal file
63
src/Ombi.Schedule/Jobs/Ombi/IssuesPurge.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Core.Settings;
|
||||
using Ombi.Settings.Settings.Models;
|
||||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Schedule.Jobs.Ombi
|
||||
{
|
||||
public class IssuesPurge : IIssuesPurge
|
||||
{
|
||||
public IssuesPurge(IRepository<Issues> issuesRepo, ISettingsService<IssueSettings> issueSettings)
|
||||
{
|
||||
_issuesRepository = issuesRepo;
|
||||
_settings = issueSettings;
|
||||
_settings.ClearCache();
|
||||
}
|
||||
|
||||
private readonly IRepository<Issues> _issuesRepository;
|
||||
private readonly ISettingsService<IssueSettings> _settings;
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
var settings = await _settings.GetSettingsAsync();
|
||||
if (!settings.DeleteIssues)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var now = DateTime.Now.AddDays(-settings.DaysAfterResolvedToDelete).Date;
|
||||
var resolved = _issuesRepository.GetAll().Where(x => x.Status == IssueStatus.Resolved);
|
||||
var toDelete = resolved.Where(x => x.ResovledDate.HasValue && x.ResovledDate.Value.Date <= now);
|
||||
|
||||
foreach (var d in toDelete)
|
||||
{
|
||||
d.Status = IssueStatus.Deleted;
|
||||
}
|
||||
|
||||
await _issuesRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
private bool _disposed;
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_issuesRepository?.Dispose();
|
||||
_settings?.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -98,7 +98,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
// Get the Content
|
||||
var plexContent = _plex.GetAll().Include(x => x.Episodes).AsNoTracking();
|
||||
var embyContent = _emby.GetAll().Include(x => x.Episodes).AsNoTracking();
|
||||
var lidarrContent = _lidarrAlbumRepository.GetAll().AsNoTracking();
|
||||
var lidarrContent = _lidarrAlbumRepository.GetAll().Where(x => x.FullyAvailable).AsNoTracking();
|
||||
|
||||
var addedLog = _recentlyAddedLog.GetAll();
|
||||
var addedPlexMovieLogIds = addedLog.Where(x => x.Type == RecentlyAddedType.Plex && x.ContentType == ContentType.Parent).Select(x => x.ContentId);
|
||||
|
@ -654,7 +654,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
AddInfoTable(sb);
|
||||
|
||||
var title = "";
|
||||
if (!String.IsNullOrEmpty(info.premiered) && info.premiered.Length > 4)
|
||||
if (!string.IsNullOrEmpty(info.premiered) && info.premiered.Length > 4)
|
||||
{
|
||||
title = $"{t.Title} ({info.premiered.Remove(4)})";
|
||||
} else
|
||||
|
@ -715,7 +715,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
}
|
||||
}
|
||||
|
||||
public string BuildEpisodeList(IEnumerable<int> orderedEpisodes)
|
||||
public static string BuildEpisodeList(IEnumerable<int> orderedEpisodes)
|
||||
{
|
||||
var epSb = new StringBuilder();
|
||||
var previousEpisodes = new List<int>();
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
public class OmbiAutomaticUpdater : IOmbiAutomaticUpdater
|
||||
{
|
||||
public OmbiAutomaticUpdater(ILogger<OmbiAutomaticUpdater> log, IChangeLogProcessor service,
|
||||
ISettingsService<UpdateSettings> s, IProcessProvider proc, IRepository<ApplicationConfiguration> appConfig)
|
||||
ISettingsService<UpdateSettings> s, IProcessProvider proc, IApplicationConfigRepository appConfig)
|
||||
{
|
||||
Logger = log;
|
||||
Processor = service;
|
||||
|
@ -48,7 +48,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
private ISettingsService<UpdateSettings> Settings { get; }
|
||||
private readonly IProcessProvider _processProvider;
|
||||
private static PerformContext Ctx { get; set; }
|
||||
private readonly IRepository<ApplicationConfiguration> _appConfig;
|
||||
private readonly IApplicationConfigRepository _appConfig;
|
||||
|
||||
public string[] GetVersion()
|
||||
{
|
||||
|
@ -252,9 +252,8 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
|
||||
private string GetArgs(UpdateSettings settings)
|
||||
{
|
||||
var config = _appConfig.GetAll();
|
||||
var url = config.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
|
||||
var storage = config.FirstOrDefault(x => x.Type == ConfigurationTypes.StoragePath);
|
||||
var url = _appConfig.Get(ConfigurationTypes.Url);
|
||||
var storage = _appConfig.Get(ConfigurationTypes.StoragePath);
|
||||
|
||||
var currentLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
var processName = (settings.ProcessName.HasValue() ? settings.ProcessName : "Ombi");
|
||||
|
@ -345,7 +344,6 @@ namespace Ombi.Schedule.Jobs.Ombi
|
|||
|
||||
if (disposing)
|
||||
{
|
||||
_appConfig?.Dispose();
|
||||
Settings?.Dispose();
|
||||
}
|
||||
_disposed = true;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|||
{
|
||||
public class RadarrSync : IRadarrSync
|
||||
{
|
||||
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IOmbiContext ctx)
|
||||
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IExternalContext ctx)
|
||||
{
|
||||
RadarrSettings = radarr;
|
||||
RadarrApi = radarrApi;
|
||||
|
@ -28,7 +28,7 @@ namespace Ombi.Schedule.Jobs.Radarr
|
|||
private ISettingsService<RadarrSettings> RadarrSettings { get; }
|
||||
private IRadarrApi RadarrApi { get; }
|
||||
private ILogger<RadarrSync> Logger { get; }
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
@ -17,7 +16,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
|||
{
|
||||
public class SickRageSync : ISickRageSync
|
||||
{
|
||||
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IOmbiContext ctx)
|
||||
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IExternalContext ctx)
|
||||
{
|
||||
_settings = s;
|
||||
_api = api;
|
||||
|
@ -29,7 +28,7 @@ namespace Ombi.Schedule.Jobs.SickRage
|
|||
private readonly ISettingsService<SickRageSettings> _settings;
|
||||
private readonly ISickRageApi _api;
|
||||
private readonly ILogger<SickRageSync> _log;
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
|||
{
|
||||
public class SonarrSync : ISonarrSync
|
||||
{
|
||||
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IOmbiContext ctx)
|
||||
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IExternalContext ctx)
|
||||
{
|
||||
_settings = s;
|
||||
_api = api;
|
||||
|
@ -31,7 +31,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
|
|||
private readonly ISettingsService<SonarrSettings> _settings;
|
||||
private readonly ISonarrApi _api;
|
||||
private readonly ILogger<SonarrSync> _log;
|
||||
private readonly IOmbiContext _ctx;
|
||||
private readonly IExternalContext _ctx;
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
|
|
|
@ -4,5 +4,8 @@
|
|||
{
|
||||
public bool Enabled { get; set; }
|
||||
public bool EnableInProgress { get; set; }
|
||||
|
||||
public bool DeleteIssues { get; set; }
|
||||
public int DaysAfterResolvedToDelete { get; set; }
|
||||
}
|
||||
}
|
|
@ -14,5 +14,6 @@
|
|||
public string RefreshMetadata { get; set; }
|
||||
public string Newsletter { get; set; }
|
||||
public string LidarrArtistSync { get; set; }
|
||||
public string IssuesPurge { get; set; }
|
||||
}
|
||||
}
|
|
@ -57,6 +57,11 @@ namespace Ombi.Settings.Settings.Models
|
|||
return Get(s.LidarrArtistSync, Cron.Hourly(40));
|
||||
}
|
||||
|
||||
public static string IssuePurge(JobSettings s)
|
||||
{
|
||||
return Get(s.IssuesPurge, Cron.Daily());
|
||||
}
|
||||
|
||||
private static string Get(string settings, string defaultCron)
|
||||
{
|
||||
return settings.HasValue() ? settings : defaultCron;
|
||||
|
|
10
src/Ombi.Settings/Settings/Models/VoteSettings.cs
Normal file
10
src/Ombi.Settings/Settings/Models/VoteSettings.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace Ombi.Settings.Settings.Models
|
||||
{
|
||||
public class VoteSettings : Settings
|
||||
{
|
||||
public bool Enabled { get; set; }
|
||||
public int MovieVoteMax { get; set; }
|
||||
public int MusicVoteMax { get; set; }
|
||||
public int TvShowVoteMax { get; set; }
|
||||
}
|
||||
}
|
68
src/Ombi.Store/Context/ExternalContext.cs
Normal file
68
src/Ombi.Store/Context/ExternalContext.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
using System.IO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public sealed class ExternalContext : DbContext, IExternalContext
|
||||
{
|
||||
private static bool _created;
|
||||
public ExternalContext()
|
||||
{
|
||||
if (_created) return;
|
||||
|
||||
_created = true;
|
||||
Database.Migrate();
|
||||
}
|
||||
|
||||
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
|
||||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
public DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
|
||||
public DbSet<SonarrCache> SonarrCache { get; set; }
|
||||
public DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||
public DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||
public DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||
public DbSet<SickRageCache> SickRageCache { get; set; }
|
||||
public DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var i = StoragePathSingleton.Instance;
|
||||
if (string.IsNullOrEmpty(i.StoragePath))
|
||||
{
|
||||
i.StoragePath = string.Empty;
|
||||
}
|
||||
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiExternal.db")}");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
builder.Entity<PlexServerContent>().HasMany(x => x.Episodes)
|
||||
.WithOne(x => x.Series)
|
||||
.HasPrincipalKey(x => x.Key)
|
||||
.HasForeignKey(x => x.GrandparentKey);
|
||||
|
||||
builder.Entity<EmbyEpisode>()
|
||||
.HasOne(p => p.Series)
|
||||
.WithMany(b => b.Episodes)
|
||||
.HasPrincipalKey(x => x.EmbyId)
|
||||
.HasForeignKey(p => p.ParentId);
|
||||
|
||||
base.OnModelCreating(builder);
|
||||
}
|
||||
|
||||
|
||||
public void Seed()
|
||||
{
|
||||
// VACUUM;
|
||||
Database.ExecuteSqlCommand("VACUUM;");
|
||||
SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
22
src/Ombi.Store/Context/IDbContext.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface IDbContext : IDisposable
|
||||
{
|
||||
EntityEntry Update(object entity);
|
||||
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
||||
int SaveChanges();
|
||||
void Seed();
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||
}
|
||||
}
|
21
src/Ombi.Store/Context/IExternalContext.cs
Normal file
21
src/Ombi.Store/Context/IExternalContext.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface IExternalContext : IDbContext
|
||||
{
|
||||
DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||
DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
DbSet<SickRageCache> SickRageCache { get; set; }
|
||||
DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||
DbSet<SonarrCache> SonarrCache { get; set; }
|
||||
DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||
}
|
||||
}
|
|
@ -9,22 +9,18 @@ using Ombi.Store.Entities.Requests;
|
|||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface IOmbiContext : IDisposable
|
||||
public interface IOmbiContext : IDbContext
|
||||
{
|
||||
int SaveChanges();
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
//DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
//DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<TEntity> Set<TEntity>() where TEntity : class;
|
||||
//DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
//DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
//DbSet<EmbyEpisode> EmbyEpisode { get; set; }
|
||||
DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
DbSet<Votes> Votes { get; set; }
|
||||
void Seed();
|
||||
DbSet<Audit> Audit { get; set; }
|
||||
DbSet<MovieRequests> MovieRequests { get; set; }
|
||||
|
@ -35,14 +31,12 @@ namespace Ombi.Store.Context
|
|||
DbSet<IssueCategory> IssueCategories { get; set; }
|
||||
DbSet<Tokens> Tokens { get; set; }
|
||||
DbSet<SonarrCache> SonarrCache { get; set; }
|
||||
DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||
EntityEntry Update(object entity);
|
||||
EntityEntry<TEntity> Update<TEntity>(TEntity entity) where TEntity : class;
|
||||
DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
DbSet<SickRageCache> SickRageCache { get; set; }
|
||||
DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||
DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||
DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||
//DbSet<SonarrEpisodeCache> SonarrEpisodeCache { get; set; }
|
||||
//DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
//DbSet<SickRageCache> SickRageCache { get; set; }
|
||||
//DbSet<LidarrArtistCache> LidarrArtistCache { get; set; }
|
||||
//DbSet<LidarrAlbumCache> LidarrAlbumCache { get; set; }
|
||||
//DbSet<SickRageEpisodeCache> SickRageEpisodeCache { get; set; }
|
||||
DbSet<RequestLog> RequestLogs { get; set; }
|
||||
DbSet<RecentlyAddedLog> RecentlyAddedLogs { get; set; }
|
||||
DbSet<RequestSubscription> RequestSubscription { get; set; }
|
||||
|
|
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
11
src/Ombi.Store/Context/ISettingsContext.cs
Normal file
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public interface ISettingsContext : IDbContext
|
||||
{
|
||||
DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
DbSet<GlobalSettings> Settings { get; set; }
|
||||
}
|
||||
}
|
|
@ -22,9 +22,11 @@ namespace Ombi.Store.Context
|
|||
}
|
||||
|
||||
public DbSet<NotificationTemplates> NotificationTemplates { get; set; }
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
public DbSet<PlexServerContent> PlexServerContent { get; set; }
|
||||
public DbSet<PlexSeasonsContent> PlexSeasonsContent { get; set; }
|
||||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
public DbSet<CouchPotatoCache> CouchPotatoCache { get; set; }
|
||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
|
@ -40,6 +42,7 @@ namespace Ombi.Store.Context
|
|||
public DbSet<IssueComments> IssueComments { get; set; }
|
||||
public DbSet<RequestLog> RequestLogs { get; set; }
|
||||
public DbSet<RecentlyAddedLog> RecentlyAddedLogs { get; set; }
|
||||
public DbSet<Votes> Votes { get; set; }
|
||||
|
||||
|
||||
public DbSet<Audit> Audit { get; set; }
|
||||
|
@ -53,7 +56,6 @@ namespace Ombi.Store.Context
|
|||
public DbSet<RequestSubscription> RequestSubscription { get; set; }
|
||||
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
|
||||
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
|
@ -84,39 +86,6 @@ namespace Ombi.Store.Context
|
|||
|
||||
public void Seed()
|
||||
{
|
||||
|
||||
// Add the tokens
|
||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (fanArt == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.FanartTv,
|
||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (movieDb == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.TheMovieDb,
|
||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
||||
if (notification == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.Notification,
|
||||
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
// VACUUM;
|
||||
Database.ExecuteSqlCommand("VACUUM;");
|
||||
|
||||
|
@ -144,6 +113,16 @@ namespace Ombi.Store.Context
|
|||
SaveChanges();
|
||||
}
|
||||
|
||||
var manageOwnRequestsRole = Roles.Where(x => x.Name == OmbiRoles.ManageOwnRequests);
|
||||
if (!manageOwnRequestsRole.Any())
|
||||
{
|
||||
Roles.Add(new IdentityRole(OmbiRoles.ManageOwnRequests)
|
||||
{
|
||||
NormalizedName = OmbiRoles.ManageOwnRequests.ToUpper()
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
// Make sure we have the API User
|
||||
var apiUserExists = Users.Any(x => x.UserName.Equals("Api", StringComparison.CurrentCultureIgnoreCase));
|
||||
if (!apiUserExists)
|
||||
|
|
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
70
src/Ombi.Store/Context/SettingsContext.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Helpers;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Context
|
||||
{
|
||||
public sealed class SettingsContext : DbContext, ISettingsContext
|
||||
{
|
||||
private static bool _created;
|
||||
public SettingsContext()
|
||||
{
|
||||
if (_created) return;
|
||||
|
||||
_created = true;
|
||||
Database.Migrate();
|
||||
}
|
||||
|
||||
public DbSet<GlobalSettings> Settings { get; set; }
|
||||
public DbSet<ApplicationConfiguration> ApplicationConfigurations { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
var i = StoragePathSingleton.Instance;
|
||||
if (string.IsNullOrEmpty(i.StoragePath))
|
||||
{
|
||||
i.StoragePath = string.Empty;
|
||||
}
|
||||
optionsBuilder.UseSqlite($"Data Source={Path.Combine(i.StoragePath, "OmbiSettings.db")}");
|
||||
}
|
||||
|
||||
public void Seed()
|
||||
{
|
||||
// Add the tokens
|
||||
var fanArt = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (fanArt == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.FanartTv,
|
||||
Value = "4b6d983efa54d8f45c68432521335f15"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var movieDb = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.FanartTv);
|
||||
if (movieDb == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.TheMovieDb,
|
||||
Value = "b8eabaf5608b88d0298aa189dd90bf00"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
var notification = ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Notification);
|
||||
if (notification == null)
|
||||
{
|
||||
ApplicationConfigurations.Add(new ApplicationConfiguration
|
||||
{
|
||||
Type = ConfigurationTypes.Notification,
|
||||
Value = "4f0260c4-9c3d-41ab-8d68-27cb5a593f0e"
|
||||
});
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,12 +43,8 @@ namespace Ombi.Store.Entities
|
|||
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Only used for TV Shows
|
||||
/// </summary>
|
||||
public virtual ICollection<PlexSeasonsContent> Seasons { get; set; }
|
||||
|
||||
public ICollection<PlexEpisode> Episodes { get; set; }
|
||||
public ICollection<PlexSeasonsContent> Seasons { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Plex's internal ID for this item
|
||||
|
|
|
@ -29,5 +29,6 @@ namespace Ombi.Store.Entities.Requests
|
|||
Pending = 0,
|
||||
InProgress = 1,
|
||||
Resolved = 2,
|
||||
Deleted = 3,
|
||||
}
|
||||
}
|
25
src/Ombi.Store/Entities/Votes.cs
Normal file
25
src/Ombi.Store/Entities/Votes.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
[Table("Votes")]
|
||||
public class Votes : Entity
|
||||
{
|
||||
public int RequestId { get; set; }
|
||||
public VoteType VoteType { get; set; }
|
||||
public RequestType RequestType { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public bool Deleted { get; set; }
|
||||
|
||||
[ForeignKey(nameof(UserId))]
|
||||
public OmbiUser User { get; set; }
|
||||
}
|
||||
|
||||
public enum VoteType
|
||||
{
|
||||
Upvote = 0,
|
||||
Downvote = 1
|
||||
}
|
||||
}
|
1182
src/Ombi.Store/Migrations/20180928201334_Votes.Designer.cs
generated
Normal file
1182
src/Ombi.Store/Migrations/20180928201334_Votes.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
46
src/Ombi.Store/Migrations/20180928201334_Votes.cs
Normal file
46
src/Ombi.Store/Migrations/20180928201334_Votes.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations
|
||||
{
|
||||
public partial class Votes : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Votes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
RequestId = table.Column<int>(nullable: false),
|
||||
VoteType = table.Column<int>(nullable: false),
|
||||
RequestType = table.Column<int>(nullable: false),
|
||||
UserId = table.Column<string>(nullable: true),
|
||||
Date = table.Column<DateTime>(nullable: false),
|
||||
Deleted = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Votes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Votes_AspNetUsers_UserId",
|
||||
column: x => x.UserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Votes_UserId",
|
||||
table: "Votes",
|
||||
column: "UserId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Votes");
|
||||
}
|
||||
}
|
||||
}
|
312
src/Ombi.Store/Migrations/External/20181004134907_Inital.Designer.cs
generated
vendored
Normal file
312
src/Ombi.Store/Migrations/External/20181004134907_Inital.Designer.cs
generated
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.External
|
||||
{
|
||||
[DbContext(typeof(ExternalContext))]
|
||||
[Migration("20181004134907_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TheMovieDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CouchPotatoCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EmbyContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId");
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<string>("ParentId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.ToTable("EmbyEpisode");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<int>("ArtistId");
|
||||
|
||||
b.Property<string>("ForeignAlbumId");
|
||||
|
||||
b.Property<bool>("Monitored");
|
||||
|
||||
b.Property<decimal>("PercentOfTracks");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<int>("TrackCount");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LidarrAlbumCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("ArtistId");
|
||||
|
||||
b.Property<string>("ArtistName");
|
||||
|
||||
b.Property<string>("ForeignArtistId");
|
||||
|
||||
b.Property<bool>("Monitored");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LidarrArtistCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<int>("GrandparentKey");
|
||||
|
||||
b.Property<int>("Key");
|
||||
|
||||
b.Property<int>("ParentKey");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GrandparentKey");
|
||||
|
||||
b.ToTable("PlexEpisode");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("ParentKey");
|
||||
|
||||
b.Property<int>("PlexContentId");
|
||||
|
||||
b.Property<int?>("PlexServerContentId");
|
||||
|
||||
b.Property<int>("SeasonKey");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlexServerContentId");
|
||||
|
||||
b.ToTable("PlexSeasonsContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<int>("Key");
|
||||
|
||||
b.Property<string>("Quality");
|
||||
|
||||
b.Property<string>("ReleaseYear");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PlexServerContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("HasFile");
|
||||
|
||||
b.Property<int>("TheMovieDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RadarrCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SickRageCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SickRageEpisodeCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SonarrCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<bool>("HasFile");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SonarrEpisodeCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.EmbyContent", "Series")
|
||||
.WithMany("Episodes")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasPrincipalKey("EmbyId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series")
|
||||
.WithMany("Episodes")
|
||||
.HasForeignKey("GrandparentKey")
|
||||
.HasPrincipalKey("Key")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.PlexServerContent")
|
||||
.WithMany("Seasons")
|
||||
.HasForeignKey("PlexServerContentId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
308
src/Ombi.Store/Migrations/External/20181004134907_Inital.cs
vendored
Normal file
308
src/Ombi.Store/Migrations/External/20181004134907_Inital.cs
vendored
Normal file
|
@ -0,0 +1,308 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations.External
|
||||
{
|
||||
public partial class Inital : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "CouchPotatoCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
TheMovieDbId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_CouchPotatoCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmbyContent",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
ProviderId = table.Column<string>(nullable: true),
|
||||
EmbyId = table.Column<string>(nullable: false),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
AddedAt = table.Column<DateTime>(nullable: false),
|
||||
ImdbId = table.Column<string>(nullable: true),
|
||||
TheMovieDbId = table.Column<string>(nullable: true),
|
||||
TvDbId = table.Column<string>(nullable: true),
|
||||
Url = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmbyContent", x => x.Id);
|
||||
table.UniqueConstraint("AK_EmbyContent_EmbyId", x => x.EmbyId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LidarrAlbumCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ArtistId = table.Column<int>(nullable: false),
|
||||
ForeignAlbumId = table.Column<string>(nullable: true),
|
||||
TrackCount = table.Column<int>(nullable: false),
|
||||
ReleaseDate = table.Column<DateTime>(nullable: false),
|
||||
Monitored = table.Column<bool>(nullable: false),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
PercentOfTracks = table.Column<decimal>(nullable: false),
|
||||
AddedAt = table.Column<DateTime>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LidarrAlbumCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "LidarrArtistCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ArtistId = table.Column<int>(nullable: false),
|
||||
ArtistName = table.Column<string>(nullable: true),
|
||||
ForeignArtistId = table.Column<string>(nullable: true),
|
||||
Monitored = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_LidarrArtistCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlexServerContent",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
ReleaseYear = table.Column<string>(nullable: true),
|
||||
ImdbId = table.Column<string>(nullable: true),
|
||||
TvDbId = table.Column<string>(nullable: true),
|
||||
TheMovieDbId = table.Column<string>(nullable: true),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
Url = table.Column<string>(nullable: true),
|
||||
Key = table.Column<int>(nullable: false),
|
||||
AddedAt = table.Column<DateTime>(nullable: false),
|
||||
Quality = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlexServerContent", x => x.Id);
|
||||
table.UniqueConstraint("AK_PlexServerContent_Key", x => x.Key);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RadarrCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
TheMovieDbId = table.Column<int>(nullable: false),
|
||||
HasFile = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RadarrCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SickRageCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
TvDbId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SickRageCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SickRageEpisodeCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
EpisodeNumber = table.Column<int>(nullable: false),
|
||||
TvDbId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SickRageEpisodeCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SonarrCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
TvDbId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SonarrCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SonarrEpisodeCache",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
EpisodeNumber = table.Column<int>(nullable: false),
|
||||
TvDbId = table.Column<int>(nullable: false),
|
||||
HasFile = table.Column<bool>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SonarrEpisodeCache", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmbyEpisode",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
EmbyId = table.Column<string>(nullable: true),
|
||||
EpisodeNumber = table.Column<int>(nullable: false),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
ParentId = table.Column<string>(nullable: true),
|
||||
ProviderId = table.Column<string>(nullable: true),
|
||||
AddedAt = table.Column<DateTime>(nullable: false),
|
||||
TvDbId = table.Column<string>(nullable: true),
|
||||
ImdbId = table.Column<string>(nullable: true),
|
||||
TheMovieDbId = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmbyEpisode", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_EmbyEpisode_EmbyContent_ParentId",
|
||||
column: x => x.ParentId,
|
||||
principalTable: "EmbyContent",
|
||||
principalColumn: "EmbyId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlexEpisode",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
EpisodeNumber = table.Column<int>(nullable: false),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
Key = table.Column<int>(nullable: false),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
ParentKey = table.Column<int>(nullable: false),
|
||||
GrandparentKey = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlexEpisode", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlexEpisode_PlexServerContent_GrandparentKey",
|
||||
column: x => x.GrandparentKey,
|
||||
principalTable: "PlexServerContent",
|
||||
principalColumn: "Key",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PlexSeasonsContent",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
PlexContentId = table.Column<int>(nullable: false),
|
||||
SeasonNumber = table.Column<int>(nullable: false),
|
||||
SeasonKey = table.Column<int>(nullable: false),
|
||||
ParentKey = table.Column<int>(nullable: false),
|
||||
PlexServerContentId = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PlexSeasonsContent", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_PlexSeasonsContent_PlexServerContent_PlexServerContentId",
|
||||
column: x => x.PlexServerContentId,
|
||||
principalTable: "PlexServerContent",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmbyEpisode_ParentId",
|
||||
table: "EmbyEpisode",
|
||||
column: "ParentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlexEpisode_GrandparentKey",
|
||||
table: "PlexEpisode",
|
||||
column: "GrandparentKey");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PlexSeasonsContent_PlexServerContentId",
|
||||
table: "PlexSeasonsContent",
|
||||
column: "PlexServerContentId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "CouchPotatoCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmbyEpisode");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LidarrAlbumCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "LidarrArtistCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PlexEpisode");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PlexSeasonsContent");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RadarrCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SickRageCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SickRageEpisodeCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SonarrCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SonarrEpisodeCache");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmbyContent");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PlexServerContent");
|
||||
}
|
||||
}
|
||||
}
|
310
src/Ombi.Store/Migrations/External/ExternalContextModelSnapshot.cs
vendored
Normal file
310
src/Ombi.Store/Migrations/External/ExternalContextModelSnapshot.cs
vendored
Normal file
|
@ -0,0 +1,310 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.External
|
||||
{
|
||||
[DbContext(typeof(ExternalContext))]
|
||||
partial class ExternalContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TheMovieDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("CouchPotatoCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId")
|
||||
.IsRequired();
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EmbyContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId");
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<string>("ParentId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.ToTable("EmbyEpisode");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.LidarrAlbumCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<int>("ArtistId");
|
||||
|
||||
b.Property<string>("ForeignAlbumId");
|
||||
|
||||
b.Property<bool>("Monitored");
|
||||
|
||||
b.Property<decimal>("PercentOfTracks");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<int>("TrackCount");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LidarrAlbumCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.LidarrArtistCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("ArtistId");
|
||||
|
||||
b.Property<string>("ArtistName");
|
||||
|
||||
b.Property<string>("ForeignArtistId");
|
||||
|
||||
b.Property<bool>("Monitored");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("LidarrArtistCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<int>("GrandparentKey");
|
||||
|
||||
b.Property<int>("Key");
|
||||
|
||||
b.Property<int>("ParentKey");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("GrandparentKey");
|
||||
|
||||
b.ToTable("PlexEpisode");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("ParentKey");
|
||||
|
||||
b.Property<int>("PlexContentId");
|
||||
|
||||
b.Property<int?>("PlexServerContentId");
|
||||
|
||||
b.Property<int>("SeasonKey");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PlexServerContentId");
|
||||
|
||||
b.ToTable("PlexSeasonsContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexServerContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("ImdbId");
|
||||
|
||||
b.Property<int>("Key");
|
||||
|
||||
b.Property<string>("Quality");
|
||||
|
||||
b.Property<string>("ReleaseYear");
|
||||
|
||||
b.Property<string>("TheMovieDbId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<string>("TvDbId");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Url");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PlexServerContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.RadarrCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<bool>("HasFile");
|
||||
|
||||
b.Property<int>("TheMovieDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("RadarrCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SickRageCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SickRageCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SickRageEpisodeCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SickRageEpisodeCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SonarrCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SonarrCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.SonarrEpisodeCache", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("EpisodeNumber");
|
||||
|
||||
b.Property<bool>("HasFile");
|
||||
|
||||
b.Property<int>("SeasonNumber");
|
||||
|
||||
b.Property<int>("TvDbId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SonarrEpisodeCache");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyEpisode", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.EmbyContent", "Series")
|
||||
.WithMany("Episodes")
|
||||
.HasForeignKey("ParentId")
|
||||
.HasPrincipalKey("EmbyId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexEpisode", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.PlexServerContent", "Series")
|
||||
.WithMany("Episodes")
|
||||
.HasForeignKey("GrandparentKey")
|
||||
.HasPrincipalKey("Key")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.PlexSeasonsContent", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.PlexServerContent")
|
||||
.WithMany("Seasons")
|
||||
.HasForeignKey("PlexServerContentId");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -916,6 +916,30 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("UserQualityProfiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("Date");
|
||||
|
||||
b.Property<bool>("Deleted");
|
||||
|
||||
b.Property<int>("RequestId");
|
||||
|
||||
b.Property<int>("RequestType");
|
||||
|
||||
b.Property<string>("UserId");
|
||||
|
||||
b.Property<int>("VoteType");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Votes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
@ -1128,6 +1152,13 @@ namespace Ombi.Store.Migrations
|
|||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.Votes", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Repository.Requests.EpisodeRequests", b =>
|
||||
{
|
||||
b.HasOne("Ombi.Store.Repository.Requests.SeasonRequests", "Season")
|
||||
|
|
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
50
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.Designer.cs
generated
Normal file
|
@ -0,0 +1,50 @@
|
|||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
[DbContext(typeof(SettingsContext))]
|
||||
[Migration("20181004132516_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Content");
|
||||
|
||||
b.Property<string>("SettingsName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GlobalSettings");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
47
src/Ombi.Store/Migrations/Settings/20181004132516_Inital.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
public partial class Inital : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ApplicationConfiguration",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Type = table.Column<int>(nullable: false),
|
||||
Value = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ApplicationConfiguration", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GlobalSettings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Content = table.Column<string>(nullable: true),
|
||||
SettingsName = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GlobalSettings", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ApplicationConfiguration");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GlobalSettings");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
// <auto-generated />
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Ombi.Store.Context;
|
||||
|
||||
namespace Ombi.Store.Migrations.Settings
|
||||
{
|
||||
[DbContext(typeof(SettingsContext))]
|
||||
partial class SettingsContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065");
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("ApplicationConfiguration");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Content");
|
||||
|
||||
b.Property<string>("SettingsName");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("GlobalSettings");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,16 +8,20 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public class ApplicationConfigRepository : IApplicationConfigRepository
|
||||
{
|
||||
public ApplicationConfigRepository(IOmbiContext ctx)
|
||||
public ApplicationConfigRepository(ISettingsContext ctx)
|
||||
{
|
||||
Ctx = ctx;
|
||||
}
|
||||
|
||||
private IOmbiContext Ctx { get; }
|
||||
private ISettingsContext Ctx { get; }
|
||||
|
||||
public async Task<ApplicationConfiguration> Get(ConfigurationTypes type)
|
||||
public Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type)
|
||||
{
|
||||
return await Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||
return Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type);
|
||||
}
|
||||
public ApplicationConfiguration Get(ConfigurationTypes type)
|
||||
{
|
||||
return Ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == type);
|
||||
}
|
||||
}
|
||||
}
|
105
src/Ombi.Store/Repository/BaseRepository.cs
Normal file
105
src/Ombi.Store/Repository/BaseRepository.cs
Normal file
|
@ -0,0 +1,105 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class BaseRepository<T, U> : IRepository<T> where T : Entity where U : IDbContext
|
||||
{
|
||||
public BaseRepository(U ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_db = _ctx.Set<T>();
|
||||
}
|
||||
public DbSet<T> _db { get; }
|
||||
private readonly U _ctx;
|
||||
|
||||
public async Task<T> Find(object key)
|
||||
{
|
||||
return await _db.FindAsync(key);
|
||||
}
|
||||
|
||||
public IQueryable<T> GetAll()
|
||||
{
|
||||
return _db.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task<T> FirstOrDefaultAsync(Expression<Func<T,bool>> predicate)
|
||||
{
|
||||
return await _db.FirstOrDefaultAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task AddRange(IEnumerable<T> content, bool save = true)
|
||||
{
|
||||
_db.AddRange(content);
|
||||
if (save)
|
||||
{
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T> Add(T content)
|
||||
{
|
||||
await _db.AddAsync(content);
|
||||
await _ctx.SaveChangesAsync();
|
||||
return content;
|
||||
}
|
||||
|
||||
public async Task Delete(T request)
|
||||
{
|
||||
_db.Remove(request);
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteRange(IEnumerable<T> req)
|
||||
{
|
||||
_db.RemoveRange(req);
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<int> SaveChangesAsync()
|
||||
{
|
||||
return await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
||||
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
||||
where TEntity : class
|
||||
{
|
||||
return source.Include(navigationPropertyPath);
|
||||
}
|
||||
|
||||
public async Task ExecuteSql(string sql)
|
||||
{
|
||||
await _ctx.Database.ExecuteSqlCommandAsync(sql);
|
||||
}
|
||||
|
||||
|
||||
private bool _disposed;
|
||||
// Protected implementation of Dispose pattern.
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_ctx?.Dispose();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,15 +35,15 @@ using Ombi.Store.Entities;
|
|||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class EmbyContentRepository : Repository<EmbyContent>, IEmbyContentRepository
|
||||
public class EmbyContentRepository : ExternalRepository<EmbyContent>, IEmbyContentRepository
|
||||
{
|
||||
|
||||
public EmbyContentRepository(IOmbiContext db):base(db)
|
||||
public EmbyContentRepository(IExternalContext db):base(db)
|
||||
{
|
||||
Db = db;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
private IExternalContext Db { get; }
|
||||
|
||||
|
||||
public async Task<EmbyContent> GetByImdbId(string imdbid)
|
||||
|
|
12
src/Ombi.Store/Repository/ExternalRepository.cs
Normal file
12
src/Ombi.Store/Repository/ExternalRepository.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class ExternalRepository<T> : BaseRepository<T, IExternalContext>, IExternalRepository<T> where T : Entity
|
||||
{
|
||||
public ExternalRepository(IExternalContext ctx) : base(ctx)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public interface IApplicationConfigRepository
|
||||
{
|
||||
Task<ApplicationConfiguration> Get(ConfigurationTypes type);
|
||||
Task<ApplicationConfiguration> GetAsync(ConfigurationTypes type);
|
||||
ApplicationConfiguration Get(ConfigurationTypes type);
|
||||
}
|
||||
}
|
30
src/Ombi.Store/Repository/IExternalRepository.cs
Normal file
30
src/Ombi.Store/Repository/IExternalRepository.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IExternalRepository<T> : IDisposable where T : Entity
|
||||
{
|
||||
Task<T> Find(object key);
|
||||
IQueryable<T> GetAll();
|
||||
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate);
|
||||
Task AddRange(IEnumerable<T> content, bool save = true);
|
||||
Task<T> Add(T content);
|
||||
Task DeleteRange(IEnumerable<T> req);
|
||||
Task Delete(T request);
|
||||
Task<int> SaveChangesAsync();
|
||||
|
||||
IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
||||
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
||||
where TEntity : class;
|
||||
|
||||
Task ExecuteSql(string sql);
|
||||
DbSet<T> _db { get; }
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ using Ombi.Store.Entities;
|
|||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IPlexContentRepository : IRepository<PlexServerContent>
|
||||
public interface IPlexContentRepository : IExternalRepository<PlexServerContent>
|
||||
{
|
||||
Task<bool> ContentExists(string providerId);
|
||||
Task<PlexServerContent> Get(string providerId);
|
||||
|
|
|
@ -36,15 +36,15 @@ using Ombi.Store.Entities;
|
|||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class PlexServerContentRepository : Repository<PlexServerContent>, IPlexContentRepository
|
||||
public class PlexServerContentRepository : ExternalRepository<PlexServerContent>, IPlexContentRepository
|
||||
{
|
||||
|
||||
public PlexServerContentRepository(IOmbiContext db) : base(db)
|
||||
public PlexServerContentRepository(IExternalContext db) : base(db)
|
||||
{
|
||||
Db = db;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
private IExternalContext Db { get; }
|
||||
|
||||
|
||||
public async Task<bool> ContentExists(string providerId)
|
||||
|
|
|
@ -1,105 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class Repository<T> : IRepository<T> where T : Entity
|
||||
public class Repository<T> : BaseRepository<T,IOmbiContext>, IRepository<T> where T : Entity
|
||||
{
|
||||
public Repository(IOmbiContext ctx)
|
||||
public Repository(IOmbiContext ctx) : base(ctx)
|
||||
{
|
||||
_ctx = ctx;
|
||||
_db = _ctx.Set<T>();
|
||||
}
|
||||
public DbSet<T> _db { get; }
|
||||
private readonly IOmbiContext _ctx;
|
||||
|
||||
public async Task<T> Find(object key)
|
||||
{
|
||||
return await _db.FindAsync(key);
|
||||
}
|
||||
|
||||
public IQueryable<T> GetAll()
|
||||
{
|
||||
return _db.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task<T> FirstOrDefaultAsync(Expression<Func<T,bool>> predicate)
|
||||
{
|
||||
return await _db.FirstOrDefaultAsync(predicate);
|
||||
}
|
||||
|
||||
public async Task AddRange(IEnumerable<T> content, bool save = true)
|
||||
{
|
||||
_db.AddRange(content);
|
||||
if (save)
|
||||
{
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T> Add(T content)
|
||||
{
|
||||
await _db.AddAsync(content);
|
||||
await _ctx.SaveChangesAsync();
|
||||
return content;
|
||||
}
|
||||
|
||||
public async Task Delete(T request)
|
||||
{
|
||||
_db.Remove(request);
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task DeleteRange(IEnumerable<T> req)
|
||||
{
|
||||
_db.RemoveRange(req);
|
||||
await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<int> SaveChangesAsync()
|
||||
{
|
||||
return await _ctx.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public IIncludableQueryable<TEntity, TProperty> Include<TEntity, TProperty>(
|
||||
IQueryable<TEntity> source, Expression<Func<TEntity, TProperty>> navigationPropertyPath)
|
||||
where TEntity : class
|
||||
{
|
||||
return source.Include(navigationPropertyPath);
|
||||
}
|
||||
|
||||
public async Task ExecuteSql(string sql)
|
||||
{
|
||||
await _ctx.Database.ExecuteSqlCommandAsync(sql);
|
||||
}
|
||||
|
||||
|
||||
private bool _disposed;
|
||||
// Protected implementation of Dispose pattern.
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_ctx?.Dispose();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,13 +12,13 @@ namespace Ombi.Store.Repository
|
|||
{
|
||||
public class SettingsJsonRepository : ISettingsRepository
|
||||
{
|
||||
public SettingsJsonRepository(IOmbiContext ctx, ICacheService mem)
|
||||
public SettingsJsonRepository(ISettingsContext ctx, ICacheService mem)
|
||||
{
|
||||
Db = ctx;
|
||||
_cache = mem;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
private ISettingsContext Db { get; }
|
||||
private readonly ICacheService _cache;
|
||||
|
||||
public GlobalSettings Insert(GlobalSettings entity)
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
|
||||
<PackageReference Include="Moq" Version="4.7.99" />
|
||||
<PackageReference Include="Nunit" Version="3.8.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.7.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.0" />
|
||||
<PackageReference Include="Nunit" Version="3.10.1" />
|
||||
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
14
src/Ombi/Attributes/UserAttribute.cs
Normal file
14
src/Ombi/Attributes/UserAttribute.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Microsoft.AspNetCore.Authorization;
|
||||
using Ombi.Helpers;
|
||||
|
||||
|
||||
namespace Ombi.Attributes
|
||||
{
|
||||
public class UserAttribute : AuthorizeAttribute
|
||||
{
|
||||
public UserAttribute()
|
||||
{
|
||||
Roles = "ManageOwnRequests";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -54,6 +54,12 @@
|
|||
<i class="fa fa-user"></i> {{ 'NavigationBar.UserManagement' | translate }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul *ngIf="voteEnabled" class="nav navbar-nav">
|
||||
<li id="Vote" [routerLinkActive]="['active']">
|
||||
<a [routerLink]="['/vote']">
|
||||
<i class="fa fa-thumbs-o-up"></i> {{ 'NavigationBar.Vote' | translate }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul *ngIf="hasRole('Admin') || hasRole('PowerUser')" class="nav navbar-nav donation">
|
||||
<li>
|
||||
|
@ -88,13 +94,13 @@
|
|||
</a>
|
||||
</li>
|
||||
<li [routerLinkActive]="['active']" class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<a href="#" id="userDropdown" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<i class="fa fa-user"></i>{{ 'NavigationBar.Welcome' | translate: {username: user.name} }}
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li [routerLinkActive]="['active']">
|
||||
<a [routerLink]="['/usermanagement/updatedetails']">
|
||||
<a id="updateUserDetails" [routerLink]="['/usermanagement/updatedetails']">
|
||||
<i class="fa fa-key"></i>{{ 'NavigationBar.UpdateDetails' | translate }}</a>
|
||||
</li>
|
||||
<li [routerLinkActive]="['active']">
|
||||
|
@ -111,37 +117,37 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li [ngClass]="{'active': 'en' === translate.currentLang}">
|
||||
<a (click)="translate.use('en')" [translate]="'NavigationBar.Language.English'"></a>
|
||||
<a (click)="translate.use('en')">English</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'fr' === translate.currentLang}">
|
||||
<a (click)="translate.use('fr')" [translate]="'NavigationBar.Language.French'"></a>
|
||||
<a (click)="translate.use('fr')">Français</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'da' === translate.currentLang}">
|
||||
<a (click)="translate.use('da')" [translate]="'NavigationBar.Language.Danish'"></a>
|
||||
<a (click)="translate.use('da')">Dansk</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'de' === translate.currentLang}">
|
||||
<a (click)="translate.use('de')" [translate]="'NavigationBar.Language.German'"></a>
|
||||
<a (click)="translate.use('de')">Deutsch</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'it' === translate.currentLang}">
|
||||
<a (click)="translate.use('it')" [translate]="'NavigationBar.Language.Italian'"></a>
|
||||
<a (click)="translate.use('it')">Italiano</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'es' === translate.currentLang}">
|
||||
<a (click)="translate.use('es')" [translate]="'NavigationBar.Language.Spanish'"></a>
|
||||
<a (click)="translate.use('es')">Español</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'nl' === translate.currentLang}">
|
||||
<a (click)="translate.use('nl')" [translate]="'NavigationBar.Language.Dutch'"></a>
|
||||
<a (click)="translate.use('nl')">Nederlands</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'no' === translate.currentLang}">
|
||||
<a (click)="translate.use('no')" [translate]="'NavigationBar.Language.Norwegian'"></a>
|
||||
<a (click)="translate.use('no')">Norsk</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'pt' === translate.currentLang}">
|
||||
<a (click)="translate.use('pt')" [translate]="'NavigationBar.Language.BrazillianPortuguese'"></a>
|
||||
<a (click)="translate.use('pt')">Português (Brasil)</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'pl' === translate.currentLang}">
|
||||
<a (click)="translate.use('pl')" [translate]="'NavigationBar.Language.Polish'"></a>
|
||||
<a (click)="translate.use('pl')">Polski</a>
|
||||
</li>
|
||||
<li [ngClass]="{'active': 'sv' === translate.currentLang}">
|
||||
<a (click)="translate.use('sv')" [translate]="'NavigationBar.Language.Swedish'"></a>
|
||||
<a (click)="translate.use('sv')">Svenska</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -23,6 +23,7 @@ export class AppComponent implements OnInit {
|
|||
public updateAvailable: boolean;
|
||||
public currentUrl: string;
|
||||
public userAccessToken: string;
|
||||
public voteEnabled = false;
|
||||
|
||||
private checkedForUpdate: boolean;
|
||||
|
||||
|
@ -54,6 +55,7 @@ export class AppComponent implements OnInit {
|
|||
|
||||
this.settingsService.getCustomization().subscribe(x => this.customizationSettings = x);
|
||||
this.settingsService.issueEnabled().subscribe(x => this.issuesEnabled = x);
|
||||
this.settingsService.voteEnabled().subscribe(x => this.voteEnabled =x);
|
||||
|
||||
this.router.events.subscribe((event: NavigationStart) => {
|
||||
this.currentUrl = event.url;
|
||||
|
|
|
@ -15,7 +15,7 @@ import { TranslateLoader, TranslateModule } from "@ngx-translate/core";
|
|||
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
|
||||
import { CookieService } from "ng2-cookies";
|
||||
import { GrowlModule } from "primeng/components/growl/growl";
|
||||
import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, SharedModule, SidebarModule, TooltipModule } from "primeng/primeng";
|
||||
import { ButtonModule, CaptchaModule, ConfirmationService, ConfirmDialogModule, DataTableModule, DialogModule, OverlayPanelModule, SharedModule, SidebarModule, TooltipModule } from "primeng/primeng";
|
||||
|
||||
// Components
|
||||
import { AppComponent } from "./app.component";
|
||||
|
@ -55,6 +55,7 @@ const routes: Routes = [
|
|||
{ loadChildren: "./requests/requests.module#RequestsModule", path: "requests" },
|
||||
{ loadChildren: "./search/search.module#SearchModule", path: "search" },
|
||||
{ loadChildren: "./recentlyAdded/recentlyAdded.module#RecentlyAddedModule", path: "recentlyadded" },
|
||||
{ loadChildren: "./vote/vote.module#VoteModule", path: "vote" },
|
||||
];
|
||||
|
||||
// AoT requires an exported function for factories
|
||||
|
@ -97,6 +98,7 @@ export function JwtTokenGetter() {
|
|||
CaptchaModule,
|
||||
TooltipModule,
|
||||
ConfirmDialogModule,
|
||||
OverlayPanelModule,
|
||||
CommonModule,
|
||||
JwtModule.forRoot({
|
||||
config: {
|
||||
|
|
|
@ -59,6 +59,7 @@ export interface INewsletterNotificationSettings extends INotificationSettings {
|
|||
notificationTemplate: INotificationTemplates;
|
||||
disableMovies: boolean;
|
||||
disableTv: boolean;
|
||||
disableMusic: boolean;
|
||||
externalEmails: string[];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
export enum RequestType {
|
||||
movie = 1,
|
||||
tvShow = 2,
|
||||
|
||||
}
|
||||
|
||||
// NEW WORLD
|
||||
|
|
|
@ -144,11 +144,14 @@ export interface IJobSettings {
|
|||
newsletter: string;
|
||||
plexRecentlyAddedSync: string;
|
||||
lidarrArtistSync: string;
|
||||
issuesPurge: string;
|
||||
}
|
||||
|
||||
export interface IIssueSettings extends ISettings {
|
||||
enabled: boolean;
|
||||
enableInProgress: boolean;
|
||||
deleteIssues: boolean;
|
||||
daysAfterResolvedToDelete: number;
|
||||
}
|
||||
|
||||
export interface IAuthenticationSettings extends ISettings {
|
||||
|
@ -228,3 +231,10 @@ export interface IJobSettingsViewModel {
|
|||
result: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface IVoteSettings extends ISettings {
|
||||
enabled: boolean;
|
||||
movieVoteMax: number;
|
||||
musicVoteMax: number;
|
||||
tvShowVoteMax: number;
|
||||
}
|
||||
|
|
30
src/Ombi/ClientApp/app/interfaces/IVote.ts
Normal file
30
src/Ombi/ClientApp/app/interfaces/IVote.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
export interface IVoteViewModel {
|
||||
requestId: number;
|
||||
requestType: RequestTypes;
|
||||
image: string;
|
||||
background: string;
|
||||
upvotes: number;
|
||||
downvotes: number;
|
||||
title: string;
|
||||
description: string;
|
||||
alreadyVoted: boolean;
|
||||
myVote: VoteType;
|
||||
}
|
||||
|
||||
export interface IVoteEngineResult {
|
||||
result: boolean;
|
||||
message: string;
|
||||
isError: boolean;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export enum RequestTypes {
|
||||
TvShow = 0,
|
||||
Movie = 1,
|
||||
Album = 2,
|
||||
}
|
||||
|
||||
export enum VoteType {
|
||||
Upvote = 0,
|
||||
Downvote = 1,
|
||||
}
|
|
@ -16,3 +16,4 @@ export * from "./IIssues";
|
|||
export * from "./IRecentlyAdded";
|
||||
export * from "./ILidarr";
|
||||
export * from "./ISearchMusicResult";
|
||||
export * from "./IVote";
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
<div class="messages msg_sent"> <i *ngIf="isAdmin" style="float:right;" class="fa fa-times" aria-hidden="true" (click)="deleteComment(comment.id)"></i>
|
||||
<p>{{comment.comment}}</p>
|
||||
<time>{{comment.username}} • {{comment.date | date:'short'}}</time>
|
||||
<time>{{comment.username}} • {{comment.date | amLocal | amDateFormat: 'l LT'}}</time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -33,7 +33,7 @@ include the remember me checkbox
|
|||
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-success" type="submit" [translate]="'Login.SignInButton'"></button>
|
||||
<button class="btn btn-success" type="submit" data-test='signinbtn' [translate]="'Login.SignInButton'"></button>
|
||||
<a [routerLink]="['/reset']" class="forgot-password col-md-12">
|
||||
<b [translate]="'Login.ForgottenPassword'"></b>
|
||||
</a>
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<div class="col-sm-5 small-padding">
|
||||
<div>
|
||||
<a href="http://www.imdb.com/title/{{request.imdbId}}/" target="_blank">
|
||||
<h4 class="request-title">{{request.title}} ({{request.releaseDate | date: 'yyyy'}})</h4>
|
||||
<h4 class="request-title">{{request.title}} ({{request.releaseDate | amLocal | amDateFormat: 'YYYY'}})</h4>
|
||||
</a>
|
||||
</div>
|
||||
<br />
|
||||
|
@ -93,9 +93,9 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div id="releaseDate">{{ 'Requests.TheatricalRelease' | translate: {date: request.releaseDate | date: 'mediumDate'} }}</div>
|
||||
<div *ngIf="request.digitalReleaseDate" id="digitalReleaseDate">{{ 'Requests.DigitalRelease' | translate: {date: request.digitalReleaseDate | date: 'mediumDate'} }}</div>
|
||||
<div id="requestedDate">{{ 'Requests.RequestDate' | translate }} {{request.requestedDate | date}}</div>
|
||||
<div id="releaseDate">{{ 'Requests.TheatricalRelease' | translate: {date: request.releaseDate | amLocal | amDateFormat: 'LL'} }}</div>
|
||||
<div *ngIf="request.digitalReleaseDate" id="digitalReleaseDate">{{ 'Requests.DigitalRelease' | translate: {date: request.digitalReleaseDate | amLocal | amDateFormat: 'LL'} }}</div>
|
||||
<div id="requestedDate">{{ 'Requests.RequestDate' | translate }} {{request.requestedDate | amLocal | amDateFormat: 'LL'}}</div>
|
||||
<br />
|
||||
</div>
|
||||
<div *ngIf="isAdmin">
|
||||
|
@ -129,7 +129,7 @@
|
|||
</form>
|
||||
|
||||
<!--Radarr Root Folder-->
|
||||
<div *ngIf="radarrRootFolders" class="btn-group btn-split" id="rootFolderBtn">
|
||||
<div *ngIf="radarrRootFolders?.length > 1" class="btn-group btn-split" id="rootFolderBtn">
|
||||
<button type="button" class="btn btn-sm btn-warning-outline">
|
||||
<i class="fa fa-plus"></i> {{ 'Requests.ChangeRootFolder' | translate }}
|
||||
</button>
|
||||
|
@ -145,7 +145,7 @@
|
|||
</div>
|
||||
|
||||
<!--Radarr Quality Profiles -->
|
||||
<div *ngIf="radarrProfiles" class="btn-group btn-split" id="changeQualityBtn">
|
||||
<div *ngIf="radarrProfiles?.length > 1" class="btn-group btn-split" id="changeQualityBtn">
|
||||
<button type="button" class="btn btn-sm btn-warning-outline">
|
||||
<i class="fa fa-plus"></i> {{ 'Requests.ChangeQualityProfile' | translate }}
|
||||
</button>
|
||||
|
@ -166,11 +166,7 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="removeBtn">
|
||||
<button (click)="removeRequest(request)" style="text-align: right" class="btn btn-sm btn-danger-outline delete">
|
||||
<i class="fa fa-minus"></i> {{ 'Requests.Remove' | translate }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
<form id="markBtnGroup">
|
||||
<button id="unavailableBtn" *ngIf="request.available" (click)="changeAvailability(request, false)" style="text-align: right"
|
||||
|
@ -185,6 +181,13 @@
|
|||
|
||||
|
||||
|
||||
</div>
|
||||
<div *ngIf="isAdmin || isRequestUser(request)">
|
||||
<form id="removeBtn">
|
||||
<button (click)="removeRequest(request)" style="text-align: right" class="btn btn-sm btn-danger-outline delete">
|
||||
<i class="fa fa-minus"></i> {{ 'Requests.Remove' | translate }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="dropdown" *ngIf="issueCategories && issuesEnabled" id="issuesBtn">
|
||||
<button class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
|
||||
|
|
|
@ -218,6 +218,13 @@ export class MovieRequestsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
public isRequestUser(request: IMovieRequests) {
|
||||
if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private filterActiveStyle(el: any) {
|
||||
el = el.toElement || el.relatedTarget || el.target || el.srcElement;
|
||||
|
||||
|
@ -365,4 +372,5 @@ export class MovieRequestsComponent implements OnInit {
|
|||
req.backgroundPath = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + "https://image.tmdb.org/t/p/w1280" + req.background + ")");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<div>
|
||||
<h4>
|
||||
<a href="" target="_blank">
|
||||
{{request.title}}
|
||||
{{request.title | truncate: 36}}
|
||||
</a>
|
||||
|
||||
</h4>
|
||||
|
@ -97,8 +97,8 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div id="releaseDate">{{ 'Requests.ReleaseDate' | translate: {date: request.releaseDate | date: 'mediumDate'} }}</div>
|
||||
<div id="requestedDate">{{ 'Requests.RequestDate' | translate }} {{request.requestedDate | date: 'mediumDate'}}</div>
|
||||
<div id="releaseDate">{{ 'Requests.ReleaseDate' | translate: {date: request.releaseDate | amLocal | amDateFormat: 'LL'} }}</div>
|
||||
<div id="requestedDate">{{ 'Requests.RequestDate' | translate }} {{request.requestedDate | amLocal | amDateFormat: 'LL'}}</div>
|
||||
<br />
|
||||
</div>
|
||||
<!-- <div *ngIf="isAdmin">
|
||||
|
@ -169,11 +169,7 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="removeBtn" class="col-md-6">
|
||||
<button (click)="removeRequest(request)" style="text-align: right" class="btn btn-sm btn-danger-outline delete">
|
||||
<i class="fa fa-minus"></i> {{ 'Requests.Remove' | translate }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
<form id="markBtnGroup">
|
||||
<button id="unavailableBtn" *ngIf="request.available" (click)="changeAvailability(request, false)" style="text-align: right"
|
||||
|
@ -188,6 +184,13 @@
|
|||
|
||||
|
||||
|
||||
</div>
|
||||
<div *ngIf="isAdmin || isRequestUser(request)">
|
||||
<form id="removeBtn">
|
||||
<button (click)="removeRequest(request)" style="text-align: right" class="btn btn-sm btn-danger-outline delete">
|
||||
<i class="fa fa-minus"></i> {{ 'Requests.Remove' | translate }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="dropdown" *ngIf="issueCategories && issuesEnabled" id="issuesBtn">
|
||||
<button class="btn btn-sm btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true"
|
||||
|
|
|
@ -198,6 +198,13 @@ export class MusicRequestsComponent implements OnInit {
|
|||
this.loadInit();
|
||||
}
|
||||
|
||||
public isRequestUser(request: IAlbumRequest) {
|
||||
if (request.requestedUser.userName === this.auth.claims().name) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// public subscribe(request: IAlbumRequest) {
|
||||
// request.subscribed = true;
|
||||
// this.requestService.subscribeToMovie(request.id)
|
||||
|
@ -348,4 +355,5 @@ export class MusicRequestsComponent implements OnInit {
|
|||
req.background = this.sanitizer.bypassSecurityTrustStyle
|
||||
("url(" + req.cover + ")");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
<button id="denyBtn" *ngIf="!child.denied" type="button" (click)="deny(child)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> {{ 'Requests.Deny' | translate }}</button>
|
||||
|
||||
</div>
|
||||
<div *ngIf="isAdmin || isRequestUser(child)">
|
||||
<button id="removeBtn" type="button" (click)="removeRequest(child)" class="btn btn-sm btn-danger-outline deny"><i class="fa fa-times"></i> {{ 'Requests.Remove' | translate }}</button>
|
||||
</div>
|
||||
|
||||
|
@ -71,7 +73,7 @@
|
|||
{{ep.title}}
|
||||
</td>
|
||||
<td>
|
||||
{{ep.airDate | date: 'dd/MM/yyyy' }}
|
||||
{{ep.airDate | amLocal | amDateFormat: 'L' }}
|
||||
</td>
|
||||
<td>
|
||||
<span *ngIf="child.denied" class="label label-danger" id="deniedLabel" [translate]="'Common.Denied'"></span>
|
||||
|
|
|
@ -10,6 +10,7 @@ import { NotificationService, RequestService } from "../services";
|
|||
export class TvRequestChildrenComponent {
|
||||
@Input() public childRequests: IChildRequests[];
|
||||
@Input() public isAdmin: boolean;
|
||||
@Input() public currentUser: string;
|
||||
|
||||
@Output() public requestDeleted = new EventEmitter<number>();
|
||||
|
||||
|
@ -110,10 +111,18 @@ export class TvRequestChildrenComponent {
|
|||
});
|
||||
}
|
||||
|
||||
public isRequestUser(request: IChildRequests) {
|
||||
if (request.requestedUser.userName === this.currentUser) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private removeRequestFromUi(key: IChildRequests) {
|
||||
const index = this.childRequests.indexOf(key, 0);
|
||||
if (index > -1) {
|
||||
this.childRequests.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<div class="col-sm-5 small-padding">
|
||||
<div>
|
||||
<a href="http://www.imdb.com/title/{{node.imdbId}}/" target="_blank">
|
||||
<h4 class="request-title">{{node.title}} ({{node.releaseDate | date: 'yyyy'}})</h4>
|
||||
<h4 class="request-title">{{node.title}} ({{node.releaseDate | amLocal | amDateFormat: 'YYYY'}})</h4>
|
||||
</a>
|
||||
</div>
|
||||
<br />
|
||||
|
@ -32,7 +32,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div>Release Date: {{node.releaseDate | date}}</div>
|
||||
<div>Release Date: {{node.releaseDate | amLocal | amDateFormat: 'LL'}}</div>
|
||||
<div *ngIf="isAdmin">
|
||||
<div *ngIf="node.qualityOverrideTitle" class="quality-override">{{ 'Requests.QualityOverride' | translate }}
|
||||
<span>{{node.qualityOverrideTitle}} </span>
|
||||
|
@ -50,7 +50,7 @@
|
|||
<i class="fa fa-plus"></i> View</button>
|
||||
<div *ngIf="isAdmin">
|
||||
<!--Sonarr Root Folder-->
|
||||
<div *ngIf="sonarrRootFolders" class="btn-group btn-split" id="rootFolderBtn">
|
||||
<div *ngIf="sonarrRootFolders?.length > 1" class="btn-group btn-split" id="rootFolderBtn">
|
||||
<button type="button" class="btn btn-sm btn-warning-outline">
|
||||
<i class="fa fa-plus"></i> {{ 'Requests.ChangeRootFolder' | translate }}
|
||||
</button>
|
||||
|
@ -66,7 +66,7 @@
|
|||
</div>
|
||||
|
||||
<!--Sonarr Quality Profiles -->
|
||||
<div *ngIf="sonarrProfiles" class="btn-group btn-split" id="changeQualityBtn">
|
||||
<div *ngIf="sonarrProfiles?.length > 1" class="btn-group btn-split" id="changeQualityBtn">
|
||||
<button type="button" class="btn btn-sm btn-warning-outline">
|
||||
<i class="fa fa-plus"></i> {{ 'Requests.ChangeQualityProfile' | translate }}
|
||||
</button>
|
||||
|
@ -99,7 +99,7 @@
|
|||
</div>
|
||||
<!--This is the section that holds the child seasons if they want to specify specific episodes-->
|
||||
<div *ngIf="node.open">
|
||||
<tvrequests-children [childRequests]="node.childRequests" [isAdmin]="isAdmin" (requestDeleted)="childRequestDeleted($event)"></tvrequests-children>
|
||||
<tvrequests-children [childRequests]="node.childRequests" [isAdmin]="isAdmin" [currentUser]="currentUser" (requestDeleted)="childRequestDeleted($event)"></tvrequests-children>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
|
|
@ -20,6 +20,7 @@ export class TvRequestsComponent implements OnInit {
|
|||
public searchChanged = new Subject<string>();
|
||||
public searchText: string;
|
||||
public isAdmin: boolean;
|
||||
public currentUser: string;
|
||||
public showChildDialogue = false; // This is for the child modal popup
|
||||
public selectedSeason: ITvRequests;
|
||||
public defaultPoster: string;
|
||||
|
@ -48,6 +49,7 @@ export class TvRequestsComponent implements OnInit {
|
|||
private readonly platformLocation: PlatformLocation) {
|
||||
|
||||
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
|
||||
this.currentUser = this.auth.claims().name;
|
||||
if (this.isAdmin) {
|
||||
this.sonarrService.getQualityProfilesWithoutSettings()
|
||||
.subscribe(x => this.sonarrProfiles = x);
|
||||
|
|
|
@ -41,11 +41,11 @@
|
|||
<div class="col-sm-8 small-padding">
|
||||
<div>
|
||||
<a href="https://www.themoviedb.org/movie/{{result.id}}/" target="_blank">
|
||||
<h4>{{result.title}} ({{result.releaseDate | date: 'yyyy'}})</h4>
|
||||
<h4>{{result.title}} ({{result.releaseDate | amLocal | amDateFormat: 'YYYY'}})</h4>
|
||||
</a>
|
||||
<span class="tags">
|
||||
<span *ngIf="result.releaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | date: 'mediumDate'} }}</span>
|
||||
<span *ngIf="result.digitalReleaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.DigitalDate' | translate: {date: result.digitalReleaseDate | date: 'mediumDate'} }}</span>
|
||||
<span *ngIf="result.releaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.TheatricalRelease' | translate: {date: result.releaseDate | amLocal | amDateFormat: 'LL'} }}</span>
|
||||
<span *ngIf="result.digitalReleaseDate" class="label label-info" id="releaseDateLabel" target="_blank">{{ 'Search.DigitalDate' | translate: {date: result.digitalReleaseDate | amLocal | amDateFormat: 'LL'} }}</span>
|
||||
|
||||
<a *ngIf="result.homepage" href="{{result.homepage}}" id="homePageLabel" target="_blank"><span class="label label-info" [translate]="'Search.Movies.HomePage'"></span></a>
|
||||
|
||||
|
|
|
@ -67,10 +67,10 @@
|
|||
<div class="col-sm-8">
|
||||
<div>
|
||||
<a href="https://www.themoviedb.org/movie/{{result.id}}/" target="_blank">
|
||||
<h4>{{result.title}} ({{result.releaseDate | date: 'yyyy'}})</h4>
|
||||
<h4>{{result.title}} ({{result.releaseDate | amLocal | amDateFormat: 'YYYY'}})</h4>
|
||||
</a>
|
||||
|
||||
<span *ngIf="result.releaseDate" class="label label-info" target="_blank">Release Date: {{result.releaseDate | date: 'dd/MM/yyyy'}}</span>
|
||||
<span *ngIf="result.releaseDate" class="label label-info" target="_blank">Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}}</span>
|
||||
|
||||
<a *ngIf="result.homepage" href="{{result.homepage}}" id="homepageLabel" target="_blank">
|
||||
<span class="label label-info">HomePage</span>
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
|
||||
<ng-template [ngIf]="result.releaseDate">
|
||||
<span class="label label-info" id="availableLabel">Release Date: {{result.releaseDate | date:'yyyy-MM-dd'}}</span>
|
||||
<span class="label label-info" id="availableLabel">Release Date: {{result.releaseDate | amLocal | amDateFormat: 'L'}}</span>
|
||||
</ng-template>
|
||||
<ng-template [ngIf]="result.rating">
|
||||
<span class="label label-info" id="availableLabel">{{result.rating}}/10</span>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue