This commit is contained in:
Jamie Rees 2019-12-17 13:13:33 +00:00
commit e24ad04be9
166 changed files with 10901 additions and 1058 deletions

1
.gitignore vendored
View file

@ -246,3 +246,4 @@ _Pvt_Extensions
# Ignore local vscode config # Ignore local vscode config
*.vscode *.vscode
/src/Ombi/database.json

View file

@ -4,6 +4,77 @@
### **New Features** ### **New Features**
- Update login.component.ts. [Jamie]
- Update CHANGELOG.md. [Jamie]
- Updated SlackNotification.cs. [Tim]
### **Fixes**
- Fixed the issue where we couldn't always pick up stuff on the sync. [tidusjar]
- Removed hangfire completly from Ombi. [tidusjar]
- Fixed the notifications issue. [tidusjar]
- Fixed the issues where the DB was being disposed too early. [tidusjar]
- Fixed an error with the newsletter with the new db structure. [tidusjar]
- Output some useful stuff to the about window regarding the databases. [tidusjar]
- Fixed the migration for combined databases. [tidusjar]
- Fixed the issue where exisitng databases would now fail due to the DB structure changes. [tidusjar]
- Finished it! [tidusjar]
- Got MySql working. [tidusjar]
- Got the new DB structure in place. [tidusjar]
- Fix for #3219. [tidusjar]
- Fixed the error in the newsletter. [tidusjar]
- Fixed #3208. [tidusjar]
- Use tags and autocomplete for excluded keywords. [Taylor Buchanan]
- Add comments to clarify filter decisions. [Taylor Buchanan]
- Fix TS import order. [Taylor Buchanan]
- Add adult movie filtering. [Taylor Buchanan]
- Fix search bar overlap on mobile. [Taylor Buchanan]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- New translations en.json (Slovak) [Jamie]
- Add SK lang. [Jamie Rees]
- Add the migration to the correct database... #3214. [tidusjar]
- Hopefully provide a fix now for #2998 Theory is that the refresh metadata was using stale data and then overriding the availbility that just happened on that media item. [tidusjar]
## v3.0.4817 (2019-10-12)
### **New Features**
- Added better support for Jellyfin, we will now auto detect if it's a jellyfin server after pressing the discover button. [tidusjar] - Added better support for Jellyfin, we will now auto detect if it's a jellyfin server after pressing the discover button. [tidusjar]
- Update aspnetcore.yml. [Jamie] - Update aspnetcore.yml. [Jamie]
@ -34,6 +105,8 @@
### **Fixes** ### **Fixes**
- Gitchangelog. [tidusjar]
- Fixed #3078. [tidusjar] - Fixed #3078. [tidusjar]
- Fixes issue #3195 The new string extension method ToHttpsUrl ensures that URLs starting with "https" are no longer turned into "httpss" The commit also replaces all occurances of the error prone .Replace("http", "https") in the whole solution. [msdeibel] - Fixes issue #3195 The new string extension method ToHttpsUrl ensures that URLs starting with "https" are no longer turned into "httpss" The commit also replaces all occurances of the error prone .Replace("http", "https") in the whole solution. [msdeibel]

View file

@ -74,6 +74,7 @@ Supported notifications:
* Pushover * Pushover
* Mattermost * Mattermost
* Telegram * Telegram
* Webhook
### The difference between Version 3 and 2 ### The difference between Version 3 and 2

View file

@ -0,0 +1,10 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Ombi.Api.Webhook
{
public interface IWebhookApi
{
Task PushAsync(string endpoint, string accessToken, IDictionary<string, string> parameters);
}
}

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<Version></Version>
<PackageVersion></PackageVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,40 @@
using Newtonsoft.Json.Serialization;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
namespace Ombi.Api.Webhook
{
public class WebhookApi : IWebhookApi
{
private static readonly CamelCasePropertyNamesContractResolver _nameResolver = new CamelCasePropertyNamesContractResolver();
public WebhookApi(IApi api)
{
_api = api;
}
private readonly IApi _api;
public async Task PushAsync(string baseUrl, string accessToken, IDictionary<string, string> parameters)
{
var request = new Request("/", baseUrl, HttpMethod.Post);
if (!string.IsNullOrWhiteSpace(accessToken))
{
request.AddHeader("Access-Token", accessToken);
}
var body = parameters.ToDictionary(
x => _nameResolver.GetResolvedPropertyName(x.Key),
x => x.Value
);
request.ApplicationJsonContentType();
request.AddJsonBody(body);
await _api.Request(request);
}
}
}

View file

@ -93,24 +93,7 @@ namespace Ombi.Api
public void AddQueryString(string key, string value) public void AddQueryString(string key, string value)
{ {
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return; if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return;
_modified = FullUri.AddQueryParameter(key, value);
var builder = new UriBuilder(FullUri);
var startingTag = string.Empty;
var hasQuery = false;
if (string.IsNullOrEmpty(builder.Query))
{
startingTag = "?";
}
else
{
hasQuery = true;
startingTag = builder.Query.Contains("?") ? "&" : "?";
}
builder.Query = hasQuery
? $"{builder.Query}{startingTag}{key}={value}"
: $"{startingTag}{key}={value}";
_modified = builder.Uri;
} }
public void AddJsonBody(object obj) public void AddJsonBody(object obj)

View file

@ -188,11 +188,7 @@ namespace Ombi.Core.Engine
var requests = await (OrderMovies(allRequests, orderFilter.OrderType)).Skip(position).Take(count) var requests = await (OrderMovies(allRequests, orderFilter.OrderType)).Skip(position).Take(count)
.ToListAsync(); .ToListAsync();
requests.ForEach(async x => await CheckForSubscription(shouldHide, requests);
{
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
await CheckForSubscription(shouldHide, x);
});
return new RequestsViewModel<MovieRequests> return new RequestsViewModel<MovieRequests>
{ {
Collection = requests, Collection = requests,
@ -251,26 +247,30 @@ namespace Ombi.Core.Engine
allRequests = await MovieRepository.GetWithUser().ToListAsync(); allRequests = await MovieRepository.GetWithUser().ToListAsync();
} }
allRequests.ForEach(async x => await CheckForSubscription(shouldHide, allRequests);
{
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
await CheckForSubscription(shouldHide, x);
});
return allRequests; return allRequests;
} }
private async Task CheckForSubscription(HideResult shouldHide, MovieRequests x) private async Task CheckForSubscription(HideResult shouldHide, List<MovieRequests> movieRequests)
{ {
if (shouldHide.UserId == x.RequestedUserId) var requestIds = movieRequests.Select(x => x.Id);
var sub = await _subscriptionRepository.GetAll().Where(s =>
s.UserId == shouldHide.UserId && requestIds.Contains(s.RequestId) && s.RequestType == RequestType.Movie)
.ToListAsync();
foreach (var x in movieRequests)
{ {
x.ShowSubscribe = false; x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
} if (shouldHide.UserId == x.RequestedUserId)
else {
{ x.ShowSubscribe = false;
x.ShowSubscribe = true; }
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => else
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.Movie); {
x.Subscribed = sub != null; x.ShowSubscribe = true;
var hasSub = sub.FirstOrDefault(r => r.RequestId == x.Id);
x.Subscribed = hasSub != null;
}
} }
} }
@ -293,11 +293,8 @@ namespace Ombi.Core.Engine
} }
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList(); var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
results.ForEach(async x => await CheckForSubscription(shouldHide, results);
{
x.PosterPath = PosterPathHelper.FixPosterPath(x.PosterPath);
await CheckForSubscription(shouldHide, x);
});
return results; return results;
} }
@ -321,7 +318,7 @@ namespace Ombi.Core.Engine
request.Denied = true; request.Denied = true;
request.DeniedReason = denyReason; request.DeniedReason = denyReason;
// We are denying a request // We are denying a request
NotificationHelper.Notify(request, NotificationType.RequestDeclined); await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
await MovieRepository.Update(request); await MovieRepository.Update(request);
return new RequestEngineResult return new RequestEngineResult
@ -349,7 +346,7 @@ namespace Ombi.Core.Engine
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification); var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
if (canNotify.Success) if (canNotify.Success)
{ {
NotificationHelper.Notify(request, NotificationType.RequestApproved); await NotificationHelper.Notify(request, NotificationType.RequestApproved);
} }
if (request.Approved) if (request.Approved)
@ -465,7 +462,7 @@ namespace Ombi.Core.Engine
request.Available = true; request.Available = true;
request.MarkedAsAvailable = DateTime.Now; request.MarkedAsAvailable = DateTime.Now;
NotificationHelper.Notify(request, NotificationType.RequestAvailable); await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
await MovieRepository.Update(request); await MovieRepository.Update(request);
return new RequestEngineResult return new RequestEngineResult
@ -481,8 +478,8 @@ namespace Ombi.Core.Engine
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification); var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
if (result.Success) if (result.Success)
{ {
NotificationHelper.NewRequest(model); await NotificationHelper.NewRequest(model);
} }
await _requestLog.Add(new RequestLog await _requestLog.Add(new RequestLog
@ -493,7 +490,7 @@ namespace Ombi.Core.Engine
RequestType = RequestType.Movie, RequestType = RequestType.Movie,
}); });
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!", RequestId = model.Id}; return new RequestEngineResult { Result = true, Message = $"{movieName} has been successfully added!", RequestId = model.Id };
} }
public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user) public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
@ -533,7 +530,7 @@ namespace Ombi.Core.Engine
return new RequestQuotaCountModel() return new RequestQuotaCountModel()
{ {
HasLimit = true, HasLimit = true,
Limit = limit, Limit = limit,
Remaining = count, Remaining = count,
NextRequest = DateTime.SpecifyKind(oldestRequestedAt.AddDays(7), DateTimeKind.Utc), NextRequest = DateTime.SpecifyKind(oldestRequestedAt.AddDays(7), DateTimeKind.Utc),

View file

@ -314,7 +314,7 @@ namespace Ombi.Core.Engine
request.Denied = true; request.Denied = true;
request.DeniedReason = reason; request.DeniedReason = reason;
// We are denying a request // We are denying a request
NotificationHelper.Notify(request, NotificationType.RequestDeclined); await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
await MusicRepository.Update(request); await MusicRepository.Update(request);
return new RequestEngineResult return new RequestEngineResult
@ -342,7 +342,7 @@ namespace Ombi.Core.Engine
var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification); var canNotify = await RunSpecificRule(request, SpecificRules.CanSendNotification);
if (canNotify.Success) if (canNotify.Success)
{ {
NotificationHelper.Notify(request, NotificationType.RequestApproved); await NotificationHelper.Notify(request, NotificationType.RequestApproved);
} }
if (request.Approved) if (request.Approved)
@ -469,7 +469,7 @@ namespace Ombi.Core.Engine
request.Available = true; request.Available = true;
request.MarkedAsAvailable = DateTime.Now; request.MarkedAsAvailable = DateTime.Now;
NotificationHelper.Notify(request, NotificationType.RequestAvailable); await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
await MusicRepository.Update(request); await MusicRepository.Update(request);
return new RequestEngineResult return new RequestEngineResult
@ -486,7 +486,7 @@ namespace Ombi.Core.Engine
var result = await RunSpecificRule(model, SpecificRules.CanSendNotification); var result = await RunSpecificRule(model, SpecificRules.CanSendNotification);
if (result.Success) if (result.Success)
{ {
NotificationHelper.NewRequest(model); await NotificationHelper.NewRequest(model);
} }
await _requestLog.Add(new RequestLog await _requestLog.Add(new RequestLog

View file

@ -156,10 +156,9 @@ namespace Ombi.Core.Engine
.ThenInclude(x => x.Episodes) .ThenInclude(x => x.Episodes)
.OrderByDescending(x => x.ChildRequests.Select(y => y.RequestedDate).FirstOrDefault()) .OrderByDescending(x => x.ChildRequests.Select(y => y.RequestedDate).FirstOrDefault())
.Skip(position).Take(count).ToListAsync(); .Skip(position).Take(count).ToListAsync();
}
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); }
await CheckForSubscription(shouldHide, allRequests);
return new RequestsViewModel<TvRequests> return new RequestsViewModel<TvRequests>
{ {
@ -194,7 +193,8 @@ namespace Ombi.Core.Engine
{ {
return new RequestsViewModel<TvRequests>(); return new RequestsViewModel<TvRequests>();
} }
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
await CheckForSubscription(shouldHide, allRequests);
return new RequestsViewModel<TvRequests> return new RequestsViewModel<TvRequests>
{ {
@ -216,7 +216,7 @@ namespace Ombi.Core.Engine
allRequests = await TvRepository.Get().ToListAsync(); allRequests = await TvRepository.Get().ToListAsync();
} }
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); await CheckForSubscription(shouldHide, allRequests);
return allRequests; return allRequests;
} }
@ -236,7 +236,7 @@ namespace Ombi.Core.Engine
allRequests = await TvRepository.GetLite().ToListAsync(); allRequests = await TvRepository.GetLite().ToListAsync();
} }
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); await CheckForSubscription(shouldHide, allRequests);
return allRequests; return allRequests;
} }
@ -255,7 +255,7 @@ namespace Ombi.Core.Engine
request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync(); request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync();
} }
await CheckForSubscription(shouldHide, request); await CheckForSubscription(shouldHide, new List<TvRequests>{request});
return request; return request;
} }
@ -304,7 +304,7 @@ namespace Ombi.Core.Engine
allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync(); allRequests = await TvRepository.GetChild().Include(x => x.SeasonRequests).Where(x => x.ParentRequestId == tvId).ToListAsync();
} }
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); await CheckForSubscription(shouldHide, allRequests);
return allRequests; return allRequests;
} }
@ -323,7 +323,7 @@ namespace Ombi.Core.Engine
} }
var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync(); var results = await allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToListAsync();
results.ForEach(async r => { await CheckForSubscription(shouldHide, r); }); await CheckForSubscription(shouldHide, results);
return results; return results;
} }
@ -388,7 +388,7 @@ namespace Ombi.Core.Engine
if (request.Approved) if (request.Approved)
{ {
NotificationHelper.Notify(request, NotificationType.RequestApproved); await NotificationHelper.Notify(request, NotificationType.RequestApproved);
// Autosend // Autosend
await TvSender.Send(request); await TvSender.Send(request);
} }
@ -411,7 +411,7 @@ namespace Ombi.Core.Engine
request.Denied = true; request.Denied = true;
request.DeniedReason = reason; request.DeniedReason = reason;
await TvRepository.UpdateChild(request); await TvRepository.UpdateChild(request);
NotificationHelper.Notify(request, NotificationType.RequestDeclined); await NotificationHelper.Notify(request, NotificationType.RequestDeclined);
return new RequestEngineResult return new RequestEngineResult
{ {
Result = true Result = true
@ -420,7 +420,7 @@ namespace Ombi.Core.Engine
public async Task<ChildRequests> UpdateChildRequest(ChildRequests request) public async Task<ChildRequests> UpdateChildRequest(ChildRequests request)
{ {
await TvRepository.UpdateChild(request); await TvRepository.UpdateChild(request);
return request; return request;
} }
@ -438,14 +438,14 @@ namespace Ombi.Core.Engine
// Delete the parent // Delete the parent
TvRepository.Db.TvRequests.Remove(parent); TvRepository.Db.TvRequests.Remove(parent);
} }
await TvRepository.Db.SaveChangesAsync(); await TvRepository.Db.SaveChangesAsync();
} }
public async Task RemoveTvRequest(int requestId) public async Task RemoveTvRequest(int requestId)
{ {
var request = await TvRepository.Get().FirstOrDefaultAsync(x => x.Id == requestId); var request = await TvRepository.Get().FirstOrDefaultAsync(x => x.Id == requestId);
await TvRepository.Delete(request); await TvRepository.Delete(request);
} }
public async Task<bool> UserHasRequest(string userId) public async Task<bool> UserHasRequest(string userId)
@ -499,7 +499,7 @@ namespace Ombi.Core.Engine
} }
} }
await TvRepository.UpdateChild(request); await TvRepository.UpdateChild(request);
NotificationHelper.Notify(request, NotificationType.RequestAvailable); await NotificationHelper.Notify(request, NotificationType.RequestAvailable);
return new RequestEngineResult return new RequestEngineResult
{ {
Result = true, Result = true,
@ -520,26 +520,32 @@ namespace Ombi.Core.Engine
} }
} }
private async Task CheckForSubscription(HideResult shouldHide, TvRequests x) private async Task CheckForSubscription(HideResult shouldHide, List<TvRequests> x)
{ {
foreach (var tv in x.ChildRequests) foreach (var tvRequest in x)
{ {
await CheckForSubscription(shouldHide, tv); await CheckForSubscription(shouldHide, tvRequest.ChildRequests);
} }
} }
private async Task CheckForSubscription(HideResult shouldHide, ChildRequests x) private async Task CheckForSubscription(HideResult shouldHide, List<ChildRequests> childRequests)
{ {
if (shouldHide.UserId == x.RequestedUserId) var sub = _subscriptionRepository.GetAll();
var childIds = childRequests.Select(x => x.Id);
var relevantSubs = await sub.Where(s =>
s.UserId == shouldHide.UserId && childIds.Contains(s.Id) && s.RequestType == RequestType.TvShow).ToListAsync();
foreach (var x in childRequests)
{ {
x.ShowSubscribe = false; if (shouldHide.UserId == x.RequestedUserId)
} {
else x.ShowSubscribe = false;
{ }
x.ShowSubscribe = true; else
var sub = await _subscriptionRepository.GetAll().FirstOrDefaultAsync(s => {
s.UserId == shouldHide.UserId && s.RequestId == x.Id && s.RequestType == RequestType.TvShow); x.ShowSubscribe = true;
x.Subscribed = sub != null; var result = relevantSubs.FirstOrDefault(s => s.RequestId == x.Id);
x.Subscribed = result != null;
}
} }
} }
@ -560,7 +566,7 @@ namespace Ombi.Core.Engine
return await AfterRequest(model.ChildRequests.FirstOrDefault()); return await AfterRequest(model.ChildRequests.FirstOrDefault());
} }
private static List<ChildRequests> SortEpisodes(List<ChildRequests> items) private static List<ChildRequests> SortEpisodes(List<ChildRequests> items)
{ {
foreach (var value in items) foreach (var value in items)
{ {
@ -578,7 +584,7 @@ namespace Ombi.Core.Engine
var sendRuleResult = await RunSpecificRule(model, SpecificRules.CanSendNotification); var sendRuleResult = await RunSpecificRule(model, SpecificRules.CanSendNotification);
if (sendRuleResult.Success) if (sendRuleResult.Success)
{ {
NotificationHelper.NewRequest(model); await NotificationHelper.NewRequest(model);
} }
await _requestLog.Add(new RequestLog await _requestLog.Add(new RequestLog
@ -593,11 +599,11 @@ namespace Ombi.Core.Engine
if (model.Approved) if (model.Approved)
{ {
// Autosend // Autosend
NotificationHelper.Notify(model, NotificationType.RequestApproved); await NotificationHelper.Notify(model, NotificationType.RequestApproved);
var result = await TvSender.Send(model); var result = await TvSender.Send(model);
if (result.Success) if (result.Success)
{ {
return new RequestEngineResult { Result = true, RequestId = model.Id}; return new RequestEngineResult { Result = true, RequestId = model.Id };
} }
return new RequestEngineResult return new RequestEngineResult
{ {
@ -650,10 +656,10 @@ namespace Ombi.Core.Engine
DateTime oldestRequestedAt = await log.OrderBy(x => x.RequestDate) DateTime oldestRequestedAt = await log.OrderBy(x => x.RequestDate)
.Select(x => x.RequestDate) .Select(x => x.RequestDate)
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
return new RequestQuotaCountModel() return new RequestQuotaCountModel()
{ {
HasLimit = true, HasLimit = true,
Limit = limit, Limit = limit,
Remaining = count, Remaining = count,
NextRequest = DateTime.SpecifyKind(oldestRequestedAt.AddDays(7), DateTimeKind.Utc), NextRequest = DateTime.SpecifyKind(oldestRequestedAt.AddDays(7), DateTimeKind.Utc),

View file

@ -1,5 +1,6 @@
using System; using System;
using Hangfire; using System.Collections.Generic;
using System.Threading.Tasks;
using Ombi.Core.Notifications; using Ombi.Core.Notifications;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
@ -9,13 +10,7 @@ namespace Ombi.Core
{ {
public class NotificationHelper : INotificationHelper public class NotificationHelper : INotificationHelper
{ {
public NotificationHelper(INotificationService service) public async Task NewRequest(FullBaseRequest model)
{
NotificationService = service;
}
private INotificationService NotificationService { get; }
public void NewRequest(FullBaseRequest model)
{ {
var notificationModel = new NotificationOptions var notificationModel = new NotificationOptions
{ {
@ -24,11 +19,13 @@ namespace Ombi.Core
NotificationType = NotificationType.NewRequest, NotificationType = NotificationType.NewRequest,
RequestType = model.RequestType RequestType = model.RequestType
}; };
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel)); await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, notificationModel}
});
} }
public void NewRequest(ChildRequests model) public async Task NewRequest(ChildRequests model)
{ {
var notificationModel = new NotificationOptions var notificationModel = new NotificationOptions
{ {
@ -36,11 +33,14 @@ namespace Ombi.Core
DateTime = DateTime.Now, DateTime = DateTime.Now,
NotificationType = NotificationType.NewRequest, NotificationType = NotificationType.NewRequest,
RequestType = model.RequestType RequestType = model.RequestType
}; };
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel)); await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, notificationModel}
});
} }
public void NewRequest(AlbumRequest model) public async Task NewRequest(AlbumRequest model)
{ {
var notificationModel = new NotificationOptions var notificationModel = new NotificationOptions
{ {
@ -48,38 +48,15 @@ namespace Ombi.Core
DateTime = DateTime.Now, DateTime = DateTime.Now,
NotificationType = NotificationType.NewRequest, NotificationType = NotificationType.NewRequest,
RequestType = model.RequestType RequestType = model.RequestType
}; };
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel)); await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
}
public void Notify(MovieRequests model, NotificationType type)
{
var notificationModel = new NotificationOptions
{ {
RequestId = model.Id, {JobDataKeys.NotificationOptions, notificationModel}
DateTime = DateTime.Now, });
NotificationType = type,
RequestType = model.RequestType,
Recipient = model.RequestedUser?.Email ?? string.Empty
};
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
}
public void Notify(ChildRequests model, NotificationType type)
{
var notificationModel = new NotificationOptions
{
RequestId = model.Id,
DateTime = DateTime.Now,
NotificationType = type,
RequestType = model.RequestType,
Recipient = model.RequestedUser?.Email ?? string.Empty
};
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel));
} }
public void Notify(AlbumRequest model, NotificationType type)
public async Task Notify(MovieRequests model, NotificationType type)
{ {
var notificationModel = new NotificationOptions var notificationModel = new NotificationOptions
{ {
@ -90,7 +67,50 @@ namespace Ombi.Core
Recipient = model.RequestedUser?.Email ?? string.Empty Recipient = model.RequestedUser?.Email ?? string.Empty
}; };
BackgroundJob.Enqueue(() => NotificationService.Publish(notificationModel)); await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, notificationModel}
});
}
public async Task Notify(ChildRequests model, NotificationType type)
{
var notificationModel = new NotificationOptions
{
RequestId = model.Id,
DateTime = DateTime.Now,
NotificationType = type,
RequestType = model.RequestType,
Recipient = model.RequestedUser?.Email ?? string.Empty
};
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, notificationModel}
});
}
public async Task Notify(AlbumRequest model, NotificationType type)
{
var notificationModel = new NotificationOptions
{
RequestId = model.Id,
DateTime = DateTime.Now,
NotificationType = type,
RequestType = model.RequestType,
Recipient = model.RequestedUser?.Email ?? string.Empty
};
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, notificationModel}
});
}
public async Task Notify(NotificationOptions model)
{
await OmbiQuartz.TriggerJob(nameof(INotificationService), "Notifications", new Dictionary<string, object>
{
{JobDataKeys.NotificationOptions, model}
});
} }
} }
} }

View file

@ -0,0 +1,15 @@

using System.Collections.Generic;
using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities;
namespace Ombi.Core.Models.UI
{
/// <summary>
/// The view model for the notification settings page
/// </summary>
/// <seealso cref="WebhookSettings" />
public class WebhookNotificationViewModel : WebhookSettings
{
}
}

View file

@ -11,7 +11,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="AutoMapper" Version="6.1.1" /> <PackageReference Include="AutoMapper" Version="6.1.1" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" /> <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="3.2.0" />
<PackageReference Include="Hangfire" Version="1.6.22" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.2" />
<PackageReference Include="MiniProfiler.AspNetCore" Version="4.0.0-alpha6-79" /> <PackageReference Include="MiniProfiler.AspNetCore" Version="4.0.0-alpha6-79" />

View file

@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore;
using Ombi.Core.Authentication; using Ombi.Core.Authentication;
using Ombi.Core.Rule.Interfaces; using Ombi.Core.Rule.Interfaces;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests; using Ombi.Store.Entities.Requests;
namespace Ombi.Core.Rule.Rules.Request namespace Ombi.Core.Rule.Rules.Request

View file

@ -7,12 +7,12 @@ namespace Ombi.Core.Rule.Rules.Request
{ {
public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest> public class SonarrCacheRequestRule : BaseRequestRule, IRules<BaseRequest>
{ {
public SonarrCacheRequestRule(IExternalContext ctx) public SonarrCacheRequestRule(ExternalContext ctx)
{ {
_ctx = ctx; _ctx = ctx;
} }
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public Task<RuleResult> Execute(BaseRequest obj) public Task<RuleResult> Execute(BaseRequest obj)
{ {

View file

@ -34,12 +34,12 @@ namespace Ombi.Core.Rule.Rules.Search
{ {
public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel> public class SonarrCacheSearchRule : BaseSearchRule, IRules<SearchViewModel>
{ {
public SonarrCacheSearchRule(IExternalContext ctx) public SonarrCacheSearchRule(ExternalContext ctx)
{ {
_ctx = ctx; _ctx = ctx;
} }
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public Task<RuleResult> Execute(SearchViewModel obj) public Task<RuleResult> Execute(SearchViewModel obj)
{ {

View file

@ -10,12 +10,12 @@ namespace Ombi.Core.Rule.Rules
{ {
public class SonarrCacheRule public class SonarrCacheRule
{ {
public SonarrCacheRule(IExternalContext ctx) public SonarrCacheRule(ExternalContext ctx)
{ {
_ctx = ctx; _ctx = ctx;
} }
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public async Task<RuleResult> Execute(BaseRequest obj) public async Task<RuleResult> Execute(BaseRequest obj)
{ {

View file

@ -1,16 +1,19 @@
using Ombi.Core.Models.Requests; using System.Threading.Tasks;
using Ombi.Core.Models.Requests;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Store.Entities.Requests; using Ombi.Store.Entities.Requests;
namespace Ombi.Core namespace Ombi.Core
{ {
public interface INotificationHelper public interface INotificationHelper
{ {
void NewRequest(FullBaseRequest model); Task NewRequest(FullBaseRequest model);
void NewRequest(ChildRequests model); Task NewRequest(ChildRequests model);
void NewRequest(AlbumRequest model); Task NewRequest(AlbumRequest model);
void Notify(MovieRequests model, NotificationType type); Task Notify(MovieRequests model, NotificationType type);
void Notify(ChildRequests model, NotificationType type); Task Notify(ChildRequests model, NotificationType type);
void Notify(AlbumRequest model, NotificationType type); Task Notify(AlbumRequest model, NotificationType type);
Task Notify(NotificationOptions model);
} }
} }

View file

@ -95,7 +95,7 @@ namespace Ombi.Core.Senders
Type = RequestType.Movie, Type = RequestType.Movie,
RetryCount = 0 RetryCount = 0
}); });
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
} }
} }

View file

@ -65,7 +65,7 @@ namespace Ombi.Core.Senders
Type = RequestType.Album, Type = RequestType.Album,
RetryCount = 0 RetryCount = 0
}); });
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
} }
} }

View file

@ -128,7 +128,7 @@ namespace Ombi.Core.Senders
Type = RequestType.TvShow, Type = RequestType.TvShow,
RetryCount = 0 RetryCount = 0
}); });
_notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue); await _notificationHelper.Notify(model, NotificationType.ItemAddedToFaultQueue);
} }
} }

View file

@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Security.Principal; using System.Security.Principal;
using Hangfire;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -33,6 +32,7 @@ using Ombi.Api.DogNzb;
using Ombi.Api.FanartTv; using Ombi.Api.FanartTv;
using Ombi.Api.Github; using Ombi.Api.Github;
using Ombi.Api.Gotify; using Ombi.Api.Gotify;
using Ombi.Api.Webhook;
using Ombi.Api.Lidarr; using Ombi.Api.Lidarr;
using Ombi.Api.Mattermost; using Ombi.Api.Mattermost;
using Ombi.Api.Notifications; using Ombi.Api.Notifications;
@ -123,6 +123,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IFanartTvApi, FanartTvApi>(); services.AddTransient<IFanartTvApi, FanartTvApi>();
services.AddTransient<IPushoverApi, PushoverApi>(); services.AddTransient<IPushoverApi, PushoverApi>();
services.AddTransient<IGotifyApi, GotifyApi>(); services.AddTransient<IGotifyApi, GotifyApi>();
services.AddTransient<IWebhookApi, WebhookApi>();
services.AddTransient<IMattermostApi, MattermostApi>(); services.AddTransient<IMattermostApi, MattermostApi>();
services.AddTransient<ICouchPotatoApi, CouchPotatoApi>(); services.AddTransient<ICouchPotatoApi, CouchPotatoApi>();
services.AddTransient<IDogNzbApi, DogNzbApi>(); services.AddTransient<IDogNzbApi, DogNzbApi>();
@ -135,13 +136,13 @@ namespace Ombi.DependencyInjection
} }
public static void RegisterStore(this IServiceCollection services) { public static void RegisterStore(this IServiceCollection services) {
services.AddDbContext<OmbiContext>(); //services.AddDbContext<OmbiContext>();
services.AddDbContext<SettingsContext>(); //services.AddDbContext<SettingsContext>();
services.AddDbContext<ExternalContext>(); //services.AddDbContext<ExternalContext>();
services.AddScoped<IOmbiContext, OmbiContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6 //services.AddScoped<OmbiContext, 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<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.AddScoped<ExternalContext, ExternalContext>(); // https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6
services.AddScoped<ISettingsRepository, SettingsJsonRepository>(); services.AddScoped<ISettingsRepository, SettingsJsonRepository>();
services.AddScoped<ISettingsResolver, SettingsResolver>(); services.AddScoped<ISettingsResolver, SettingsResolver>();
services.AddScoped<IPlexContentRepository, PlexServerContentRepository>(); services.AddScoped<IPlexContentRepository, PlexServerContentRepository>();
@ -174,6 +175,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IMattermostNotification, MattermostNotification>(); services.AddTransient<IMattermostNotification, MattermostNotification>();
services.AddTransient<IPushoverNotification, PushoverNotification>(); services.AddTransient<IPushoverNotification, PushoverNotification>();
services.AddTransient<IGotifyNotification, GotifyNotification>(); services.AddTransient<IGotifyNotification, GotifyNotification>();
services.AddTransient<IWebhookNotification, WebhookNotification>();
services.AddTransient<ITelegramNotification, TelegramNotification>(); services.AddTransient<ITelegramNotification, TelegramNotification>();
services.AddTransient<IMobileNotification, MobileNotification>(); services.AddTransient<IMobileNotification, MobileNotification>();
services.AddTransient<IChangeLogProcessor, ChangeLogProcessor>(); services.AddTransient<IChangeLogProcessor, ChangeLogProcessor>();
@ -181,8 +183,8 @@ namespace Ombi.DependencyInjection
public static void RegisterJobs(this IServiceCollection services) public static void RegisterJobs(this IServiceCollection services)
{ {
services.AddSingleton<IJobFactory, IoCJobFactory>(provider => new IoCJobFactory(provider)); services.AddSingleton<QuartzJobRunner>();
services.AddTransient<IBackgroundJobClient, BackgroundJobClient>(); services.AddSingleton<IJobFactory, IoCJobFactory>();
services.AddTransient<IPlexContentSync, PlexContentSync>(); services.AddTransient<IPlexContentSync, PlexContentSync>();
services.AddTransient<IEmbyContentSync, EmbyContentSync>(); services.AddTransient<IEmbyContentSync, EmbyContentSync>();

View file

@ -35,6 +35,7 @@
<ProjectReference Include="..\Ombi.Api.Telegram\Ombi.Api.Telegram.csproj" /> <ProjectReference Include="..\Ombi.Api.Telegram\Ombi.Api.Telegram.csproj" />
<ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" /> <ProjectReference Include="..\Ombi.Api.Trakt\Ombi.Api.Trakt.csproj" />
<ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" /> <ProjectReference Include="..\Ombi.Api.TvMaze\Ombi.Api.TvMaze.csproj" />
<ProjectReference Include="..\Ombi.Api.Webhook\Ombi.Api.Webhook.csproj" />
<ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" /> <ProjectReference Include="..\Ombi.Core\Ombi.Core.csproj" />
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" /> <ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
<ProjectReference Include="..\Ombi.Schedule\Ombi.Schedule.csproj" /> <ProjectReference Include="..\Ombi.Schedule\Ombi.Schedule.csproj" />

View file

@ -39,6 +39,8 @@ namespace Ombi.Helpers.Tests
yield return new TestCaseData("com.plexapp.agents.agent47://tt2543456?lang=en", ProviderIdType.Imdb).Returns("tt2543456").SetName("Unknown IMDB agent"); yield return new TestCaseData("com.plexapp.agents.agent47://tt2543456?lang=en", ProviderIdType.Imdb).Returns("tt2543456").SetName("Unknown IMDB agent");
yield return new TestCaseData("com.plexapp.agents.agent47://456822/1/1?lang=en", ProviderIdType.TvDb).Returns("456822").SetName("Unknown TvDb agent"); yield return new TestCaseData("com.plexapp.agents.agent47://456822/1/1?lang=en", ProviderIdType.TvDb).Returns("456822").SetName("Unknown TvDb agent");
yield return new TestCaseData("com.plexapp.agents.agent47://456822/999/999?lang=en", ProviderIdType.TvDb).Returns("456822").SetName("Unknown TvDb agent, large episode and season"); yield return new TestCaseData("com.plexapp.agents.agent47://456822/999/999?lang=en", ProviderIdType.TvDb).Returns("456822").SetName("Unknown TvDb agent, large episode and season");
yield return new TestCaseData("com.plexapp.agents.xbmcnfotv://153021/2/1?lang=xn", ProviderIdType.TvDb).Returns("153021").SetName("xmbc agent, tv episode");
yield return new TestCaseData("com.plexapp.agents.xbmcnfotv://153021?lang=xn", ProviderIdType.TvDb).Returns("153021").SetName("xmbc agent, tv show");
} }
} }

View file

@ -1,7 +1,8 @@
namespace Ombi.Schedule namespace Ombi.Helpers
{ {
public class JobDataKeys public class JobDataKeys
{ {
public const string RecentlyAddedSearch = "recentlyAddedSearch"; public const string RecentlyAddedSearch = "recentlyAddedSearch";
public const string NotificationOptions = nameof(NotificationOptions);
} }
} }

View file

@ -33,6 +33,7 @@ namespace Ombi.Helpers
public static EventId PushoverNotification => new EventId(4005); public static EventId PushoverNotification => new EventId(4005);
public static EventId TelegramNotifcation => new EventId(4006); public static EventId TelegramNotifcation => new EventId(4006);
public static EventId GotifyNotification => new EventId(4007); public static EventId GotifyNotification => new EventId(4007);
public static EventId WebhookNotification => new EventId(4008);
public static EventId TvSender => new EventId(5000); public static EventId TvSender => new EventId(5000);
public static EventId SonarrSender => new EventId(5001); public static EventId SonarrSender => new EventId(5001);

View file

@ -11,5 +11,6 @@
Mattermost = 6, Mattermost = 6,
Mobile = 7, Mobile = 7,
Gotify = 8, Gotify = 8,
Webhook = 9,
} }
} }

View file

@ -14,6 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" /> <PackageReference Include="Nito.AsyncEx" Version="5.0.0-pre-05" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" /> <PackageReference Include="System.Security.Claims" Version="4.3.0" />
</ItemGroup> </ItemGroup>

View file

@ -1,11 +1,10 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Helpers;
using Quartz; using Quartz;
using Quartz.Impl; using Quartz.Impl;
using Quartz.Spi; using Quartz.Spi;
namespace Ombi.Schedule namespace Ombi.Helpers
{ {
public class OmbiQuartz public class OmbiQuartz
{ {
@ -78,7 +77,12 @@ namespace Ombi.Schedule
{ {
await Scheduler.TriggerJob(new JobKey(jobName, group)); await Scheduler.TriggerJob(new JobKey(jobName, group));
} }
public static async Task TriggerJob(string jobName, string group, IDictionary<string, object> data)
{
await Scheduler.TriggerJob(new JobKey(jobName, group), new JobDataMap(data));
}
public static async Task Start() public static async Task Start()
{ {
await Scheduler.Start(); await Scheduler.Start();

View file

@ -33,14 +33,15 @@ namespace Ombi.Helpers
{ {
public class PlexHelper public class PlexHelper
{ {
private const string ImdbMatchExpression = "tt([0-9]{1,10})"; private const string ImdbMatchExpression = "tt([0-9]{1,10})";
private const string TvDbIdMatchExpression = "//[0-9]+/([0-9]{1,3})/([0-9]{1,3})"; private const string TvDbIdMatchExpression = "//[0-9]+/?([0-9]{1,3})/?([0-9]{1,3})";
public static ProviderId GetProviderIdFromPlexGuid(string guid) public static ProviderId GetProviderIdFromPlexGuid(string guid)
{ {
//com.plexapp.agents.thetvdb://269586/2/8?lang=en //com.plexapp.agents.thetvdb://269586/2/8?lang=en
//com.plexapp.agents.themoviedb://390043?lang=en //com.plexapp.agents.themoviedb://390043?lang=en
//com.plexapp.agents.imdb://tt2543164?lang=en //com.plexapp.agents.imdb://tt2543164?lang=en
// https://github.com/tidusjar/Ombi/issues/3277
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
return new ProviderId(); return new ProviderId();
@ -55,7 +56,7 @@ namespace Ombi.Helpers
{ {
TheTvDb = guidSplit[1] TheTvDb = guidSplit[1]
}; };
} else }
if (guid.Contains("themoviedb", CompareOptions.IgnoreCase)) if (guid.Contains("themoviedb", CompareOptions.IgnoreCase))
{ {
return new ProviderId return new ProviderId
@ -63,7 +64,6 @@ namespace Ombi.Helpers
TheMovieDb = guidSplit[1] TheMovieDb = guidSplit[1]
}; };
} }
else
if (guid.Contains("imdb", CompareOptions.IgnoreCase)) if (guid.Contains("imdb", CompareOptions.IgnoreCase))
{ {
return new ProviderId return new ProviderId
@ -71,74 +71,31 @@ namespace Ombi.Helpers
ImdbId = guidSplit[1] ImdbId = guidSplit[1]
}; };
} }
else
var imdbRegex = new Regex(ImdbMatchExpression, RegexOptions.Compiled);
var tvdbRegex = new Regex(TvDbIdMatchExpression, RegexOptions.Compiled);
var imdbMatch = imdbRegex.IsMatch(guid);
if (imdbMatch)
{ {
var imdbRegex = new Regex(ImdbMatchExpression, RegexOptions.Compiled); return new ProviderId
var tvdbRegex = new Regex(TvDbIdMatchExpression, RegexOptions.Compiled);
var imdbMatch = imdbRegex.IsMatch(guid);
if (imdbMatch)
{ {
return new ProviderId ImdbId = guidSplit[1]
{ };
ImdbId = guidSplit[1] }
};
} // Check if it matches the TvDb pattern
else var tvdbMatch = tvdbRegex.IsMatch(guid);
if (tvdbMatch)
{
return new ProviderId
{ {
// Check if it matches the TvDb pattern TheTvDb = guidSplit[1]
var tvdbMatch = tvdbRegex.IsMatch(guid); };
if (tvdbMatch)
{
return new ProviderId
{
TheTvDb = guidSplit[1]
};
}
}
} }
} }
return new ProviderId(); return new ProviderId();
} }
public static EpisodeModelHelper GetSeasonsAndEpisodesFromPlexGuid(string guid)
{
var ep = new EpisodeModelHelper();
//com.plexapp.agents.thetvdb://269586/2/8?lang=en
//com.plexapp.agents.themoviedb://390043?lang=en
//com.plexapp.agents.imdb://tt2543164?lang=en
if (string.IsNullOrEmpty(guid))
return null;
try
{
var guidSplit = guid.Split(new[] { '/', '?' }, StringSplitOptions.RemoveEmptyEntries);
if (guidSplit.Length > 2)
{
if (guid.Contains("thetvdb", CompareOptions.IgnoreCase))
{
ep.ProviderId = new ProviderId {TheTvDb = guidSplit[1]};
}
if (guid.Contains("themoviedb", CompareOptions.IgnoreCase))
{
ep.ProviderId = new ProviderId { TheMovieDb = guidSplit[1] };
}
if (guid.Contains("imdb", CompareOptions.IgnoreCase))
{
ep.ProviderId = new ProviderId { ImdbId = guidSplit[1] };
}
ep.SeasonNumber = int.Parse(guidSplit[2]);
ep.EpisodeNumber = int.Parse(guidSplit[3]);
}
return ep;
}
catch (Exception)
{
return ep;
}
}
public static string GetPlexMediaUrl(string machineId, int mediaId) public static string GetPlexMediaUrl(string machineId, int mediaId)
{ {
var url = var url =
@ -147,13 +104,6 @@ namespace Ombi.Helpers
} }
} }
public class EpisodeModelHelper
{
public ProviderId ProviderId { get; set; }
public int SeasonNumber { get; set; }
public int EpisodeNumber { get; set; }
}
public class ProviderId public class ProviderId
{ {
public string TheTvDb { get; set; } public string TheTvDb { get; set; }

View file

@ -20,6 +20,7 @@ namespace Ombi.Mapping.Profiles
CreateMap<MobileNotificationsViewModel, MobileNotificationSettings>().ReverseMap(); CreateMap<MobileNotificationsViewModel, MobileNotificationSettings>().ReverseMap();
CreateMap<NewsletterNotificationViewModel, NewsletterSettings>().ReverseMap(); CreateMap<NewsletterNotificationViewModel, NewsletterSettings>().ReverseMap();
CreateMap<GotifyNotificationViewModel, GotifySettings>().ReverseMap(); CreateMap<GotifyNotificationViewModel, GotifySettings>().ReverseMap();
CreateMap<WebhookNotificationViewModel, WebhookSettings>().ReverseMap();
} }
} }
} }

View file

@ -0,0 +1,6 @@
namespace Ombi.Notifications.Agents
{
public interface IWebhookNotification : INotification
{
}
}

View file

@ -0,0 +1,123 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Ombi.Api.Webhook;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.Notifications;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
namespace Ombi.Notifications.Agents
{
public class WebhookNotification : BaseNotification<WebhookSettings>, IWebhookNotification
{
public WebhookNotification(IWebhookApi api, ISettingsService<WebhookSettings> sn, ILogger<WebhookNotification> log, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t,
ISettingsService<CustomizationSettings> s, IRepository<RequestSubscription> sub, IMusicRequestRepository music,
IRepository<UserNotificationPreferences> userPref) : base(sn, r, m, t, s, log, sub, music, userPref)
{
Api = api;
Logger = log;
}
public override string NotificationName => "WebhookNotification";
private IWebhookApi Api { get; }
private ILogger<WebhookNotification> Logger { get; }
protected override bool ValidateConfiguration(WebhookSettings settings)
{
return settings.Enabled && !string.IsNullOrEmpty(settings.WebhookUrl);
}
protected override async Task NewRequest(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.NewRequest);
}
protected override async Task NewIssue(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.Issue);
}
protected override async Task IssueComment(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.IssueComment);
}
protected override async Task IssueResolved(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.IssueResolved);
}
protected override async Task AddedToRequestQueue(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.ItemAddedToFaultQueue);
}
protected override async Task RequestDeclined(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.RequestDeclined);
}
protected override async Task RequestApproved(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.RequestApproved);
}
protected override async Task AvailableRequest(NotificationOptions model, WebhookSettings settings)
{
await Run(model, settings, NotificationType.RequestAvailable);
}
protected override async Task Send(NotificationMessage model, WebhookSettings settings)
{
try
{
await Api.PushAsync(settings.WebhookUrl, settings.ApplicationToken, model.Data);
}
catch (Exception e)
{
Logger.LogError(LoggingEvents.WebhookNotification, e, "Failed to send webhook notification");
}
}
protected override async Task Test(NotificationOptions model, WebhookSettings settings)
{
var c = new NotificationMessageCurlys();
var testData = c.Curlys.ToDictionary(x => x.Key, x => x.Value);
testData[nameof(NotificationType)] = NotificationType.Test.ToString();
var notification = new NotificationMessage
{
Data = testData,
};
await Send(notification, settings);
}
private async Task Run(NotificationOptions model, WebhookSettings settings, NotificationType type)
{
var parsed = await LoadTemplate(NotificationAgent.Webhook, type, model);
if (parsed.Disabled)
{
Logger.LogInformation($"Template {type} is disabled for {NotificationAgent.Webhook}");
return;
}
var notificationData = parsed.Data.ToDictionary(x => x.Key, x => x.Value);
notificationData[nameof(NotificationType)] = type.ToString();
var notification = new NotificationMessage
{
Data = notificationData,
};
await Send(notification, settings);
}
}
}

View file

@ -1,13 +1,12 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Notifications; using Ombi.Notifications;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Quartz;
namespace Ombi.Core.Notifications namespace Ombi.Core.Notifications
{ {
public interface INotificationService public interface INotificationService : IJob
{ {
Task Publish(NotificationOptions model);
Task Publish(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings);
Task PublishTest(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings, INotification type);
} }
} }

View file

@ -9,5 +9,6 @@ namespace Ombi.Notifications.Models
public string To { get; set; } public string To { get; set; }
public Dictionary<string, string> Other { get; set; } = new Dictionary<string, string>(); public Dictionary<string, string> Other { get; set; } = new Dictionary<string, string>();
public IDictionary<string, string> Data { get; set; }
} }
} }

View file

@ -1,4 +1,6 @@
namespace Ombi.Notifications using System.Collections.Generic;
namespace Ombi.Notifications
{ {
public class NotificationMessageContent public class NotificationMessageContent
{ {
@ -6,5 +8,6 @@
public string Subject { get; set; } public string Subject { get; set; }
public string Message { get; set; } public string Message { get; set; }
public string Image { get; set; } public string Image { get; set; }
public IReadOnlyDictionary<string, string> Data { get; set; }
} }
} }

View file

@ -47,7 +47,7 @@ namespace Ombi.Notifications
body = ReplaceFields(bodyFields, parameters, body); body = ReplaceFields(bodyFields, parameters, body);
subject = ReplaceFields(subjectFields, parameters, subject); subject = ReplaceFields(subjectFields, parameters, subject);
return new NotificationMessageContent { Message = body ?? string.Empty, Subject = subject ?? string.Empty}; return new NotificationMessageContent { Message = body ?? string.Empty, Subject = subject ?? string.Empty, Data = parameters };
} }
public IEnumerable<string> ProcessConditions(IEnumerable<string> conditionalFields, IReadOnlyDictionary<string, string> parameters) public IEnumerable<string> ProcessConditions(IEnumerable<string> conditionalFields, IReadOnlyDictionary<string, string> parameters)

View file

@ -7,16 +7,56 @@ using Microsoft.Extensions.Logging;
using Ombi.Core.Notifications; using Ombi.Core.Notifications;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Quartz;
namespace Ombi.Notifications namespace Ombi.Notifications
{ {
public class NotificationService : INotificationService public class NotificationService : INotificationService
{ {
private readonly IServiceProvider _provider;
public NotificationService(IServiceProvider provider, ILogger<NotificationService> log) public NotificationService(IServiceProvider provider, ILogger<NotificationService> log)
{ {
_provider = provider;
Log = log; Log = log;
NotificationAgents = new List<INotification>(); NotificationAgents = new List<INotification>();
PopulateAgents();
}
private List<INotification> NotificationAgents { get; }
private ILogger<NotificationService> Log { get; }
/// <summary>
/// Sends a notification to the user. This one is used in normal notification scenarios
/// </summary>
/// <param name="context">The model.</param>
/// <returns></returns>
public async Task Execute(IJobExecutionContext context)
{
JobDataMap dataMap = context.MergedJobDataMap;
var model = (NotificationOptions)dataMap.Get(JobDataKeys.NotificationOptions);
foreach (var agent in NotificationAgents)
{
await NotifyAsync(agent, model);
}
}
private async Task NotifyAsync(INotification notification, NotificationOptions model)
{
try
{
await notification.NotifyAsync(model);
}
catch (Exception ex)
{
Log.LogError(LoggingEvents.Notification, ex, "Failed to notify for notification: {@notification}", notification);
}
}
private void PopulateAgents()
{
var baseSearchType = typeof(BaseNotification<>).Name; var baseSearchType = typeof(BaseNotification<>).Name;
var ass = typeof(NotificationService).GetTypeInfo().Assembly; var ass = typeof(NotificationService).GetTypeInfo().Assembly;
@ -32,7 +72,7 @@ namespace Ombi.Notifications
var services = new List<object>(); var services = new List<object>();
foreach (var param in ctor.GetParameters()) foreach (var param in ctor.GetParameters())
{ {
services.Add(provider.GetService(param.ParameterType)); services.Add(_provider.GetService(param.ParameterType));
} }
var item = Activator.CreateInstance(type, services.ToArray()); var item = Activator.CreateInstance(type, services.ToArray());
@ -40,72 +80,5 @@ namespace Ombi.Notifications
} }
} }
} }
private List<INotification> NotificationAgents { get; }
private ILogger<NotificationService> Log { get; }
/// <summary>^
/// Sends a notification to the user. This one is used in normal notification scenarios
/// </summary>
/// <param name="model">The model.</param>
/// <returns></returns>
public async Task Publish(NotificationOptions model)
{
var notificationTasks = new List<Task>();
foreach (var agent in NotificationAgents)
{
notificationTasks.Add(NotifyAsync(agent,model));
}
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
}
/// <summary>
/// Sends a notification to the user, this is usually for testing the settings.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="settings">The settings.</param>
/// <returns></returns>
public async Task Publish(NotificationOptions model, Settings.Settings.Models.Settings settings)
{
var notificationTasks = NotificationAgents.Select(notification => NotifyAsync(notification, model, settings));
await Task.WhenAll(notificationTasks).ConfigureAwait(false);
}
private async Task NotifyAsync(INotification notification, NotificationOptions model)
{
try
{
await notification.NotifyAsync(model).ConfigureAwait(false);
}
catch (Exception ex)
{
Log.LogError(LoggingEvents.Notification, ex, "Failed to notify for notification: {@notification}", notification);
}
}
private async Task NotifyAsync(INotification notification, NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings)
{
if (model.RequestId == 0)
{
throw new ArgumentException("RequestId is not set");
}
try
{
await notification.NotifyAsync(model, settings).ConfigureAwait(false);
}
catch (Exception ex)
{
throw new InvalidOperationException(ex.Message);
}
}
public async Task PublishTest(NotificationOptions model, Ombi.Settings.Settings.Models.Settings settings, INotification type)
{
await type.NotifyAsync(model, settings);
}
} }
} }

View file

@ -16,6 +16,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Ombi.Api.Discord\Ombi.Api.Discord.csproj" /> <ProjectReference Include="..\Ombi.Api.Discord\Ombi.Api.Discord.csproj" />
<ProjectReference Include="..\Ombi.Api.Gotify\Ombi.Api.Gotify.csproj" /> <ProjectReference Include="..\Ombi.Api.Gotify\Ombi.Api.Gotify.csproj" />
<ProjectReference Include="..\Ombi.Api.Webhook\Ombi.Api.Webhook.csproj" />
<ProjectReference Include="..\Ombi.Api.Mattermost\Ombi.Api.Mattermost.csproj" /> <ProjectReference Include="..\Ombi.Api.Mattermost\Ombi.Api.Mattermost.csproj" />
<ProjectReference Include="..\Ombi.Api.Notifications\Ombi.Api.Notifications.csproj" /> <ProjectReference Include="..\Ombi.Api.Notifications\Ombi.Api.Notifications.csproj" />
<ProjectReference Include="..\Ombi.Api.Pushbullet\Ombi.Api.Pushbullet.csproj" /> <ProjectReference Include="..\Ombi.Api.Pushbullet\Ombi.Api.Pushbullet.csproj" />

View file

@ -3,6 +3,7 @@ using NUnit.Framework;
using Quartz; using Quartz;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Ombi.Helpers;
namespace Ombi.Schedule.Tests namespace Ombi.Schedule.Tests
{ {
@ -12,7 +13,7 @@ namespace Ombi.Schedule.Tests
[Test] [Test]
[Ignore("Cannot get this to work")] [Ignore("Cannot get this to work")]
public async Task Test() public Task Test()
{ {
var scheduleMock = new Mock<IScheduler>(); var scheduleMock = new Mock<IScheduler>();
scheduleMock.Setup(x => x.TriggerJob(It.IsAny<JobKey>(), scheduleMock.Setup(x => x.TriggerJob(It.IsAny<JobKey>(),
@ -23,6 +24,8 @@ namespace Ombi.Schedule.Tests
scheduleMock.Verify(x => x.TriggerJob(It.Is<JobKey>(j => j.Name == "ABC"), scheduleMock.Verify(x => x.TriggerJob(It.Is<JobKey>(j => j.Name == "ABC"),
default(CancellationToken)), Times.Once); default(CancellationToken)), Times.Once);
return Task.CompletedTask;
} }
} }
public class QuartzMock : OmbiQuartz public class QuartzMock : OmbiQuartz

View file

@ -4,9 +4,9 @@ using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Castle.Components.DictionaryAdapter; using Castle.Components.DictionaryAdapter;
using Hangfire;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using Ombi.Core;
using Ombi.Core.Notifications; using Ombi.Core.Notifications;
using Ombi.Schedule.Jobs.Plex; using Ombi.Schedule.Jobs.Plex;
using Ombi.Store.Entities; using Ombi.Store.Entities;
@ -25,15 +25,15 @@ namespace Ombi.Schedule.Tests
_repo = new Mock<IPlexContentRepository>(); _repo = new Mock<IPlexContentRepository>();
_tv = new Mock<ITvRequestRepository>(); _tv = new Mock<ITvRequestRepository>();
_movie = new Mock<IMovieRequestRepository>(); _movie = new Mock<IMovieRequestRepository>();
_notify = new Mock<INotificationService>(); _notify = new Mock<INotificationHelper>();
Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, new Mock<IBackgroundJobClient>().Object, null); Checker = new PlexAvailabilityChecker(_repo.Object, _tv.Object, _movie.Object, _notify.Object, null);
} }
private Mock<IPlexContentRepository> _repo; private Mock<IPlexContentRepository> _repo;
private Mock<ITvRequestRepository> _tv; private Mock<ITvRequestRepository> _tv;
private Mock<IMovieRequestRepository> _movie; private Mock<IMovieRequestRepository> _movie;
private Mock<INotificationService> _notify; private Mock<INotificationHelper> _notify;
private PlexAvailabilityChecker Checker; private PlexAvailabilityChecker Checker;
[Test] [Test]

View file

@ -1,28 +0,0 @@
using System;
using System.Linq;
using System.Reflection;
using Hangfire;
using Microsoft.Extensions.DependencyInjection;
namespace Ombi.Schedule
{
public class IoCJobActivator : JobActivator
{
private readonly IServiceProvider _container;
public IoCJobActivator(IServiceProvider container)
{
_container = container;
}
public override object ActivateJob(Type type)
{
var scopeFactory = _container.GetService<IServiceScopeFactory>();
var scope = scopeFactory.CreateScope();
var scopedContainer = scope.ServiceProvider;
var interfaceType = type.GetTypeInfo().ImplementedInterfaces.FirstOrDefault();
var implementation = scopedContainer.GetRequiredService(interfaceType);
return implementation;
}
}
}

View file

@ -7,26 +7,18 @@ namespace Ombi.Schedule
{ {
public class IoCJobFactory : IJobFactory public class IoCJobFactory : IJobFactory
{ {
private readonly IServiceProvider _factory; private readonly IServiceProvider _serviceProvider;
public IoCJobFactory(IServiceProvider serviceProvider)
public IoCJobFactory(IServiceProvider factory)
{ {
_factory = factory; _serviceProvider = serviceProvider;
} }
public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
{ {
var scopeFactory = _factory.GetService<IServiceScopeFactory>(); return _serviceProvider.GetRequiredService<QuartzJobRunner>();
var scope = scopeFactory.CreateScope();
var scopedContainer = scope.ServiceProvider;
var implementation = scopedContainer.GetRequiredService(bundle.JobDetail.JobType) as IJob;
return implementation;
} }
public void ReturnJob(IJob job) public void ReturnJob(IJob job)
{ {
var disposable = job as IDisposable;
disposable?.Dispose();
} }
} }
} }

View file

@ -43,7 +43,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
public class CouchPotatoSync : ICouchPotatoSync public class CouchPotatoSync : ICouchPotatoSync
{ {
public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings, public CouchPotatoSync(ISettingsService<CouchPotatoSettings> cpSettings,
ICouchPotatoApi api, ILogger<CouchPotatoSync> log, IExternalContext ctx) ICouchPotatoApi api, ILogger<CouchPotatoSync> log, ExternalContext ctx)
{ {
_settings = cpSettings; _settings = cpSettings;
_api = api; _api = api;
@ -55,7 +55,7 @@ namespace Ombi.Schedule.Jobs.Couchpotato
private readonly ISettingsService<CouchPotatoSettings> _settings; private readonly ISettingsService<CouchPotatoSettings> _settings;
private readonly ICouchPotatoApi _api; private readonly ICouchPotatoApi _api;
private readonly ILogger<CouchPotatoSync> _log; private readonly ILogger<CouchPotatoSync> _log;
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
{ {

View file

@ -28,10 +28,9 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core.Notifications; using Ombi.Core;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Ombi.Schedule.Jobs.Ombi; using Ombi.Schedule.Jobs.Ombi;
@ -45,7 +44,7 @@ namespace Ombi.Schedule.Jobs.Emby
public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker public class EmbyAvaliabilityChecker : IEmbyAvaliabilityChecker
{ {
public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m, public EmbyAvaliabilityChecker(IEmbyContentRepository repo, ITvRequestRepository t, IMovieRequestRepository m,
INotificationService n, ILogger<EmbyAvaliabilityChecker> log) INotificationHelper n, ILogger<EmbyAvaliabilityChecker> log)
{ {
_repo = repo; _repo = repo;
_tvRepo = t; _tvRepo = t;
@ -57,7 +56,7 @@ namespace Ombi.Schedule.Jobs.Emby
private readonly ITvRequestRepository _tvRepo; private readonly ITvRequestRepository _tvRepo;
private readonly IMovieRequestRepository _movieRepo; private readonly IMovieRequestRepository _movieRepo;
private readonly IEmbyContentRepository _repo; private readonly IEmbyContentRepository _repo;
private readonly INotificationService _notificationService; private readonly INotificationHelper _notificationService;
private readonly ILogger<EmbyAvaliabilityChecker> _log; private readonly ILogger<EmbyAvaliabilityChecker> _log;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
@ -100,14 +99,14 @@ namespace Ombi.Schedule.Jobs.Emby
_log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient); _log.LogDebug("MovieId: {0}, RequestUser: {1}", movie.Id, recipient);
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions await _notificationService.Notify(new NotificationOptions
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable, NotificationType = NotificationType.RequestAvailable,
RequestId = movie.Id, RequestId = movie.Id,
RequestType = RequestType.Movie, RequestType = RequestType.Movie,
Recipient = recipient, Recipient = recipient,
})); });
} }
} }
await _movieRepo.Save(); await _movieRepo.Save();
@ -191,14 +190,14 @@ namespace Ombi.Schedule.Jobs.Emby
// We have fulfulled this request! // We have fulfulled this request!
child.Available = true; child.Available = true;
child.MarkedAsAvailable = DateTime.Now; child.MarkedAsAvailable = DateTime.Now;
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions await _notificationService.Notify(new NotificationOptions
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable, NotificationType = NotificationType.RequestAvailable,
RequestId = child.Id, RequestId = child.Id,
RequestType = RequestType.TvShow, RequestType = RequestType.TvShow,
Recipient = child.RequestedUser.Email Recipient = child.RequestedUser.Email
})); });
} }
} }
@ -213,7 +212,6 @@ namespace Ombi.Schedule.Jobs.Emby
if (disposing) if (disposing)
{ {
_movieRepo?.Dispose();
} }
_disposed = true; _disposed = true;
} }

View file

@ -2,18 +2,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Emby; using Ombi.Api.Emby;
using Ombi.Api.Emby.Models.Movie; using Ombi.Api.Emby.Models.Movie;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External; using Ombi.Core.Settings.Models.External;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Quartz; using Quartz;
using Serilog;
using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType; using EmbyMediaType = Ombi.Store.Entities.EmbyMediaType;
namespace Ombi.Schedule.Jobs.Emby namespace Ombi.Schedule.Jobs.Emby
@ -206,7 +203,6 @@ namespace Ombi.Schedule.Jobs.Emby
if (disposing) if (disposing)
{ {
_settings?.Dispose(); _settings?.Dispose();
_repo?.Dispose();
} }
_disposed = true; _disposed = true;
} }

View file

@ -29,11 +29,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Emby; using Ombi.Api.Emby;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External; using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Quartz; using Quartz;
@ -156,7 +156,6 @@ namespace Ombi.Schedule.Jobs.Emby
if (disposing) if (disposing)
{ {
_settings?.Dispose(); _settings?.Dispose();
_repo?.Dispose();
} }
_disposed = true; _disposed = true;
} }

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -17,22 +16,20 @@ namespace Ombi.Schedule.Jobs.Lidarr
{ {
public class LidarrAlbumSync : ILidarrAlbumSync public class LidarrAlbumSync : ILidarrAlbumSync
{ {
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IExternalContext ctx, public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, ExternalContext ctx,
IBackgroundJobClient job, ILidarrAvailabilityChecker availability) ILidarrAvailabilityChecker availability)
{ {
_lidarrSettings = lidarr; _lidarrSettings = lidarr;
_lidarrApi = lidarrApi; _lidarrApi = lidarrApi;
_logger = log; _logger = log;
_ctx = ctx; _ctx = ctx;
_job = job;
_availability = availability; _availability = availability;
} }
private readonly ISettingsService<LidarrSettings> _lidarrSettings; private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi; private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAvailabilityChecker _availability; private readonly ILidarrAvailabilityChecker _availability;
public async Task CacheContent() public async Task CacheContent()
@ -87,7 +84,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album"); _logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
} }
_job.Enqueue(() => _availability.Start()); await _availability.Start();
} }
} }
catch (Exception) catch (Exception)

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -18,22 +17,20 @@ namespace Ombi.Schedule.Jobs.Lidarr
{ {
public class LidarrArtistSync : ILidarrArtistSync public class LidarrArtistSync : ILidarrArtistSync
{ {
public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, IExternalContext ctx, public LidarrArtistSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrArtistSync> log, ExternalContext ctx,
IBackgroundJobClient background, ILidarrAlbumSync album) ILidarrAlbumSync album)
{ {
_lidarrSettings = lidarr; _lidarrSettings = lidarr;
_lidarrApi = lidarrApi; _lidarrApi = lidarrApi;
_logger = log; _logger = log;
_ctx = ctx; _ctx = ctx;
_job = background;
_albumSync = album; _albumSync = album;
} }
private readonly ISettingsService<LidarrSettings> _lidarrSettings; private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ILidarrApi _lidarrApi; private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAlbumSync _albumSync; private readonly ILidarrAlbumSync _albumSync;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
@ -84,7 +81,7 @@ namespace Ombi.Schedule.Jobs.Lidarr
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr"); _logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr");
} }
_job.Enqueue(() => _albumSync.CacheContent()); await _albumSync.CacheContent();
} }
} }
catch (Exception) catch (Exception)

View file

@ -2,10 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core.Notifications; using Ombi.Core;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Ombi.Store.Entities; using Ombi.Store.Entities;
@ -17,21 +16,18 @@ namespace Ombi.Schedule.Jobs.Lidarr
{ {
public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
{ {
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log, public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log, INotificationHelper notification)
IBackgroundJobClient job, INotificationService notification)
{ {
_cachedAlbums = albums; _cachedAlbums = albums;
_requestRepository = requests; _requestRepository = requests;
_logger = log; _logger = log;
_job = job;
_notificationService = notification; _notificationService = notification;
} }
private readonly IMusicRequestRepository _requestRepository; private readonly IMusicRequestRepository _requestRepository;
private readonly IRepository<LidarrAlbumCache> _cachedAlbums; private readonly IRepository<LidarrAlbumCache> _cachedAlbums;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IBackgroundJobClient _job; private readonly INotificationHelper _notificationService;
private readonly INotificationService _notificationService;
public async Task Start() public async Task Start()
{ {
@ -59,14 +55,15 @@ namespace Ombi.Schedule.Jobs.Lidarr
_logger.LogDebug("AlbumId: {0}, RequestUser: {1}", albumRequest.Id, recipient); _logger.LogDebug("AlbumId: {0}, RequestUser: {1}", albumRequest.Id, recipient);
_job.Enqueue(() => _notificationService.Publish(new NotificationOptions
await _notificationService.Notify(new NotificationOptions
{ {
DateTime = DateTime.Now, DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable, NotificationType = NotificationType.RequestAvailable,
RequestId = albumRequest.Id, RequestId = albumRequest.Id,
RequestType = RequestType.Album, RequestType = RequestType.Album,
Recipient = recipient, Recipient = recipient,
})); });
} }
} }
} }

View file

@ -1,5 +1,4 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire.Server;
namespace Ombi.Schedule.Jobs.Ombi namespace Ombi.Schedule.Jobs.Ombi
{ {

View file

@ -49,7 +49,6 @@ namespace Ombi.Schedule.Jobs.Ombi
if (disposing) if (disposing)
{ {
_issuesRepository?.Dispose();
_settings?.Dispose(); _settings?.Dispose();
} }
_disposed = true; _disposed = true;

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External; using Ombi.Core.Settings.Models.External;
using Ombi.Helpers; using Ombi.Helpers;
@ -99,7 +97,6 @@ namespace Ombi.Schedule.Jobs.Ombi
if (disposing) if (disposing)
{ {
_plexRepo?.Dispose();
_settings?.Dispose(); _settings?.Dispose();
} }
_disposed = true; _disposed = true;

View file

@ -37,7 +37,7 @@ namespace Ombi.Schedule.Jobs.Ombi
IMovieDbApi movieApi, ITvMazeApi tvApi, IEmailProvider email, ISettingsService<CustomizationSettings> custom, IMovieDbApi movieApi, ITvMazeApi tvApi, IEmailProvider email, ISettingsService<CustomizationSettings> custom,
ISettingsService<EmailNotificationSettings> emailSettings, INotificationTemplatesRepository templateRepo, ISettingsService<EmailNotificationSettings> emailSettings, INotificationTemplatesRepository templateRepo,
UserManager<OmbiUser> um, ISettingsService<NewsletterSettings> newsletter, ILogger<NewsletterJob> log, UserManager<OmbiUser> um, ISettingsService<NewsletterSettings> newsletter, ILogger<NewsletterJob> log,
ILidarrApi lidarrApi, IRepository<LidarrAlbumCache> albumCache, ISettingsService<LidarrSettings> lidarrSettings, ILidarrApi lidarrApi, IExternalRepository<LidarrAlbumCache> albumCache, ISettingsService<LidarrSettings> lidarrSettings,
ISettingsService<OmbiSettings> ombiSettings, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmbySettings> embySettings) ISettingsService<OmbiSettings> ombiSettings, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmbySettings> embySettings)
{ {
_plex = plex; _plex = plex;
@ -78,7 +78,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly UserManager<OmbiUser> _userManager; private readonly UserManager<OmbiUser> _userManager;
private readonly ILogger _log; private readonly ILogger _log;
private readonly ILidarrApi _lidarrApi; private readonly ILidarrApi _lidarrApi;
private readonly IRepository<LidarrAlbumCache> _lidarrAlbumRepository; private readonly IExternalRepository<LidarrAlbumCache> _lidarrAlbumRepository;
private readonly ISettingsService<LidarrSettings> _lidarrSettings; private readonly ISettingsService<LidarrSettings> _lidarrSettings;
private readonly ISettingsService<PlexSettings> _plexSettings; private readonly ISettingsService<PlexSettings> _plexSettings;
private readonly ISettingsService<EmbySettings> _embySettings; private readonly ISettingsService<EmbySettings> _embySettings;
@ -200,7 +200,7 @@ namespace Ombi.Schedule.Jobs.Ombi
continue; continue;
} }
// BCC the messages // BCC the messages
message.Bcc.Add(new MailboxAddress(user.Email, user.Email)); message.Bcc.Add(new MailboxAddress(user.Email.Trim(), user.Email.Trim()));
} }
// Send the email // Send the email
@ -714,7 +714,8 @@ namespace Ombi.Schedule.Jobs.Ombi
(key, g) => new (key, g) => new
{ {
SeasonNumber = key, SeasonNumber = key,
Episodes = g.ToList() Episodes = g.ToList(),
EpisodeAirDate = tvInfo?.seasons?.Where(x => x.season_number == key)?.Select(x => x.air_date).FirstOrDefault()
} }
); );
@ -724,7 +725,8 @@ namespace Ombi.Schedule.Jobs.Ombi
{ {
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList(); var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}"); var episodeAirDate = epInformation.EpisodeAirDate;
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString} {episodeAirDate}");
finalsb.Append("<br />"); finalsb.Append("<br />");
} }
@ -837,7 +839,8 @@ namespace Ombi.Schedule.Jobs.Ombi
(key, g) => new (key, g) => new
{ {
SeasonNumber = key, SeasonNumber = key,
Episodes = g.ToList() Episodes = g.ToList(),
EpisodeAirDate = tvInfo?.seasons?.Where(x => x.season_number == key)?.Select(x => x.air_date).FirstOrDefault()
} }
); );
@ -847,7 +850,8 @@ namespace Ombi.Schedule.Jobs.Ombi
{ {
var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList(); var orderedEpisodes = epInformation.Episodes.OrderBy(x => x.EpisodeNumber).ToList();
var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber)); var episodeString = StringHelper.BuildEpisodeList(orderedEpisodes.Select(x => x.EpisodeNumber));
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString}"); var episodeAirDate = epInformation.EpisodeAirDate;
finalsb.Append($"Season: {epInformation.SeasonNumber} - Episodes: {episodeString} {episodeAirDate}");
finalsb.Append("<br />"); finalsb.Append("<br />");
} }
@ -927,12 +931,9 @@ namespace Ombi.Schedule.Jobs.Ombi
if (disposing) if (disposing)
{ {
_plex?.Dispose();
_emby?.Dispose();
_newsletterSettings?.Dispose(); _newsletterSettings?.Dispose();
_customizationSettings?.Dispose(); _customizationSettings?.Dispose();
_emailSettings.Dispose(); _emailSettings.Dispose();
_recentlyAddedLog.Dispose();
_templateRepo?.Dispose(); _templateRepo?.Dispose();
_userManager?.Dispose(); _userManager?.Dispose();
} }

View file

@ -9,8 +9,6 @@ using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Hangfire.Server;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core.Processor; using Ombi.Core.Processor;
using Ombi.Core.Settings; using Ombi.Core.Settings;

View file

@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Emby; using Ombi.Api.Emby;
using Ombi.Api.TheMovieDb; using Ombi.Api.TheMovieDb;
@ -11,8 +9,6 @@ using Ombi.Api.TvMaze;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External; using Ombi.Core.Settings.Models.External;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Quartz; using Quartz;
@ -352,8 +348,6 @@ namespace Ombi.Schedule.Jobs.Ombi
if (disposing) if (disposing)
{ {
_plexRepo?.Dispose();
_embyRepo?.Dispose();
_plexSettings?.Dispose(); _plexSettings?.Dispose();
} }
_disposed = true; _disposed = true;

View file

@ -1,11 +1,9 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Core.Notifications; using Ombi.Core;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Notifications.Models; using Ombi.Notifications.Models;
using Ombi.Schedule.Jobs.Plex.Models; using Ombi.Schedule.Jobs.Plex.Models;
@ -20,21 +18,19 @@ namespace Ombi.Schedule.Jobs.Plex
public class PlexAvailabilityChecker : IPlexAvailabilityChecker public class PlexAvailabilityChecker : IPlexAvailabilityChecker
{ {
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies, public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
INotificationService notification, IBackgroundJobClient background, ILogger<PlexAvailabilityChecker> log) INotificationHelper notification, ILogger<PlexAvailabilityChecker> log)
{ {
_tvRepo = tvRequest; _tvRepo = tvRequest;
_repo = repo; _repo = repo;
_movieRepo = movies; _movieRepo = movies;
_notificationService = notification; _notificationService = notification;
_backgroundJobClient = background;
_log = log; _log = log;
} }
private readonly ITvRequestRepository _tvRepo; private readonly ITvRequestRepository _tvRepo;
private readonly IMovieRequestRepository _movieRepo; private readonly IMovieRequestRepository _movieRepo;
private readonly IPlexContentRepository _repo; private readonly IPlexContentRepository _repo;
private readonly INotificationService _notificationService; private readonly INotificationHelper _notificationService;
private readonly IBackgroundJobClient _backgroundJobClient;
private readonly ILogger _log; private readonly ILogger _log;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
@ -215,8 +211,6 @@ namespace Ombi.Schedule.Jobs.Plex
if (disposing) if (disposing)
{ {
_movieRepo?.Dispose();
_repo?.Dispose();
} }
_disposed = true; _disposed = true;
} }

View file

@ -29,7 +29,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Plex; using Ombi.Api.Plex;
@ -108,9 +107,8 @@ namespace Ombi.Schedule.Jobs.Plex
if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch) if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch)
{ {
Logger.LogInformation("Starting Metadata refresh"); Logger.LogInformation("Kicking off Plex Availability Checker");
// Just check what we send it await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
} }
Logger.LogInformation("Finished Plex Content Cacher, with processed content: {0}, episodes: {1}. Recently Added Scan: {2}", processedContent?.Content?.Count() ?? 0, processedContent?.Episodes?.Count() ?? 0, recentlyAddedSearch); Logger.LogInformation("Finished Plex Content Cacher, with processed content: {0}, episodes: {1}. Recently Added Scan: {2}", processedContent?.Content?.Count() ?? 0, processedContent?.Episodes?.Count() ?? 0, recentlyAddedSearch);
@ -648,7 +646,6 @@ namespace Ombi.Schedule.Jobs.Plex
if (disposing) if (disposing)
{ {
Plex?.Dispose(); Plex?.Dispose();
Repo?.Dispose();
EpisodeSync?.Dispose(); EpisodeSync?.Dispose();
} }
_disposed = true; _disposed = true;

View file

@ -2,7 +2,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Ombi.Api.Plex; using Ombi.Api.Plex;
@ -10,6 +9,7 @@ using Ombi.Api.Plex.Models;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External; using Ombi.Core.Settings.Models.External;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex.Interfaces; using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Store.Entities; using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
@ -55,7 +55,7 @@ namespace Ombi.Schedule.Jobs.Plex
_log.LogError(LoggingEvents.Cacher, e, "Caching Episodes Failed"); _log.LogError(LoggingEvents.Cacher, e, "Caching Episodes Failed");
} }
//await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex"); await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex");
} }
@ -206,7 +206,6 @@ namespace Ombi.Schedule.Jobs.Plex
if (disposing) if (disposing)
{ {
_repo?.Dispose();
_settings?.Dispose(); _settings?.Dispose();
} }
_disposed = true; _disposed = true;

View file

@ -17,7 +17,7 @@ namespace Ombi.Schedule.Jobs.Radarr
{ {
public class RadarrSync : IRadarrSync public class RadarrSync : IRadarrSync
{ {
public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, IExternalContext ctx) public RadarrSync(ISettingsService<RadarrSettings> radarr, IRadarrApi radarrApi, ILogger<RadarrSync> log, ExternalContext ctx)
{ {
RadarrSettings = radarr; RadarrSettings = radarr;
RadarrApi = radarrApi; RadarrApi = radarrApi;
@ -29,7 +29,7 @@ namespace Ombi.Schedule.Jobs.Radarr
private ISettingsService<RadarrSettings> RadarrSettings { get; } private ISettingsService<RadarrSettings> RadarrSettings { get; }
private IRadarrApi RadarrApi { get; } private IRadarrApi RadarrApi { get; }
private ILogger<RadarrSync> Logger { get; } private ILogger<RadarrSync> Logger { get; }
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1); private static readonly SemaphoreSlim SemaphoreSlim = new SemaphoreSlim(1, 1);

View file

@ -17,7 +17,7 @@ namespace Ombi.Schedule.Jobs.SickRage
{ {
public class SickRageSync : ISickRageSync public class SickRageSync : ISickRageSync
{ {
public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, IExternalContext ctx) public SickRageSync(ISettingsService<SickRageSettings> s, ISickRageApi api, ILogger<SickRageSync> l, ExternalContext ctx)
{ {
_settings = s; _settings = s;
_api = api; _api = api;
@ -29,7 +29,7 @@ namespace Ombi.Schedule.Jobs.SickRage
private readonly ISettingsService<SickRageSettings> _settings; private readonly ISettingsService<SickRageSettings> _settings;
private readonly ISickRageApi _api; private readonly ISickRageApi _api;
private readonly ILogger<SickRageSync> _log; private readonly ILogger<SickRageSync> _log;
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
{ {

View file

@ -20,7 +20,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
{ {
public class SonarrSync : ISonarrSync public class SonarrSync : ISonarrSync
{ {
public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, IExternalContext ctx) public SonarrSync(ISettingsService<SonarrSettings> s, ISonarrApi api, ILogger<SonarrSync> l, ExternalContext ctx)
{ {
_settings = s; _settings = s;
_api = api; _api = api;
@ -32,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Sonarr
private readonly ISettingsService<SonarrSettings> _settings; private readonly ISettingsService<SonarrSettings> _settings;
private readonly ISonarrApi _api; private readonly ISonarrApi _api;
private readonly ILogger<SonarrSync> _log; private readonly ILogger<SonarrSync> _log;
private readonly IExternalContext _ctx; private readonly ExternalContext _ctx;
public async Task Execute(IJobExecutionContext job) public async Task Execute(IJobExecutionContext job)
{ {

View file

@ -10,12 +10,6 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Dapper" Version="1.50.2" /> <PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="Hangfire" Version="1.6.22" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.6.22" />
<PackageReference Include="Hangfire.Console" Version="1.3.10" />
<PackageReference Include="Hangfire.MemoryStorage.Core" Version="1.4.0" />
<PackageReference Include="Hangfire.RecurringJobExtensions" Version="1.1.6" />
<PackageReference Include="Hangfire.SQLite" Version="1.4.2" />
<PackageReference Include="Serilog" Version="2.7.1" /> <PackageReference Include="Serilog" Version="2.7.1" />
<PackageReference Include="Quartz" Version="3.0.7" /> <PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="SharpCompress" Version="0.24.0" /> <PackageReference Include="SharpCompress" Version="0.24.0" />

View file

@ -2,7 +2,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Ombi.Core.Notifications;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Schedule.Jobs; using Ombi.Schedule.Jobs;
using Ombi.Schedule.Jobs.Couchpotato; using Ombi.Schedule.Jobs.Couchpotato;
using Ombi.Schedule.Jobs.Emby; using Ombi.Schedule.Jobs.Emby;
@ -53,6 +55,7 @@ namespace Ombi.Schedule
await AddEmby(s); await AddEmby(s);
await AddDvrApps(s); await AddDvrApps(s);
await AddSystem(s); await AddSystem(s);
await AddNotifications(s);
// Run Quartz // Run Quartz
await OmbiQuartz.Start(); await OmbiQuartz.Start();
@ -93,5 +96,9 @@ namespace Ombi.Schedule
await OmbiQuartz.Instance.AddJob<IEmbyAvaliabilityChecker>(nameof(IEmbyAvaliabilityChecker), "Emby", null); await OmbiQuartz.Instance.AddJob<IEmbyAvaliabilityChecker>(nameof(IEmbyAvaliabilityChecker), "Emby", null);
await OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s)); await OmbiQuartz.Instance.AddJob<IEmbyUserImporter>(nameof(IEmbyUserImporter), "Emby", JobSettingsHelper.UserImporter(s));
} }
private static async Task AddNotifications(JobSettings s)
{
await OmbiQuartz.Instance.AddJob<INotificationService>(nameof(INotificationService), "Notifications", null);
}
} }
} }

View file

@ -0,0 +1,27 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
namespace Ombi.Schedule
{
public class QuartzJobRunner : IJob
{
private readonly IServiceProvider _serviceProvider;
public QuartzJobRunner(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public async Task Execute(IJobExecutionContext context)
{
using (var scope = _serviceProvider.CreateScope())
{
var jobType = context.JobDetail.JobType;
var job = scope.ServiceProvider.GetRequiredService(jobType) as IJob;
await job.Execute(context);
}
}
}
}

View file

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace Ombi.Core.Settings.Models.External
{
public sealed class TheMovieDbSettings : Ombi.Settings.Settings.Models.Settings
{
public bool ShowAdultMovies { get; set; }
public List<int> ExcludedKeywordIds { get; set; }
}
}

View file

@ -0,0 +1,9 @@
namespace Ombi.Settings.Settings.Models.Notifications
{
public class WebhookSettings : Settings
{
public bool Enabled { get; set; }
public string WebhookUrl { get; set; }
public string ApplicationToken { get; set; }
}
}

View file

@ -5,16 +5,22 @@ using Ombi.Store.Entities;
namespace Ombi.Store.Context namespace Ombi.Store.Context
{ {
public sealed class ExternalContext : DbContext, IExternalContext public abstract class ExternalContext : DbContext
{ {
private static bool _created; protected ExternalContext(DbContextOptions<ExternalContext> options) : base(options)
public ExternalContext()
{ {
if (_created) return;
_created = true; }
Database.SetCommandTimeout(60);
Database.Migrate(); /// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected ExternalContext(DbContextOptions options)
: base(options)
{
} }
public DbSet<PlexServerContent> PlexServerContent { get; set; } public DbSet<PlexServerContent> PlexServerContent { get; set; }
@ -32,16 +38,6 @@ namespace Ombi.Store.Context
public DbSet<SickRageCache> SickRageCache { get; set; } public DbSet<SickRageCache> SickRageCache { get; set; }
public DbSet<SickRageEpisodeCache> SickRageEpisodeCache { 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) protected override void OnModelCreating(ModelBuilder builder)
{ {
builder.Entity<PlexServerContent>().HasMany(x => x.Episodes) builder.Entity<PlexServerContent>().HasMany(x => x.Episodes)
@ -57,18 +53,5 @@ namespace Ombi.Store.Context
base.OnModelCreating(builder); base.OnModelCreating(builder);
} }
public void Seed()
{
// VACUUM;
Database.ExecuteSqlCommand("VACUUM;");
using (var tran = Database.BeginTransaction())
{
SaveChanges();
tran.Commit();
}
}
} }
} }

View file

@ -1,21 +0,0 @@
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; }
}
}

View file

@ -1,46 +0,0 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Ombi.Store.Entities;
using Ombi.Store.Entities.Requests;
using Ombi.Store.Repository.Requests;
namespace Ombi.Store.Context
{
public interface IOmbiContext : IDbContext
{
//DbSet<PlexServerContent> PlexServerContent { get; set; }
//DbSet<PlexEpisode> PlexEpisode { get; set; }
DbSet<GlobalSettings> Settings { get; set; }
//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; }
DbSet<AlbumRequest> AlbumRequests { get; set; }
DbSet<TvRequests> TvRequests { get; set; }
DbSet<ChildRequests> ChildRequests { get; set; }
DbSet<EpisodeRequests> EpisodeRequests { get; set; }
DbSet<Issues> Issues { get; set; }
DbSet<IssueCategory> IssueCategories { get; set; }
DbSet<Tokens> Tokens { get; set; }
DbSet<SonarrCache> SonarrCache { 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; }
}
}

View file

@ -1,11 +0,0 @@
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; }
}
}

View file

@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class ExternalMySqlContext : ExternalContext
{
private static bool _created;
public ExternalMySqlContext(DbContextOptions<ExternalMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
}
}

View file

@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class OmbiMySqlContext : OmbiContext
{
private static bool _created;
public OmbiMySqlContext(DbContextOptions<OmbiMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
public override void Dispose()
{
base.Dispose();
}
}
}

View file

@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.MySql
{
public sealed class SettingsMySqlContext : SettingsContext
{
private static bool _created;
public SettingsMySqlContext(DbContextOptions<SettingsMySqlContext> options) : base(options)
{
if (_created) return;
_created = true;
Database.Migrate();
}
}
}

View file

@ -11,29 +11,26 @@ using Ombi.Store.Repository.Requests;
namespace Ombi.Store.Context namespace Ombi.Store.Context
{ {
public sealed class OmbiContext : IdentityDbContext<OmbiUser>, IOmbiContext public abstract class OmbiContext : IdentityDbContext<OmbiUser>
{ {
private static bool _created; protected OmbiContext(DbContextOptions<OmbiContext> options) : base(options)
public OmbiContext()
{ {
if (_created) return;
_created = true;
Database.SetCommandTimeout(60);
Database.Migrate();
} }
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected OmbiContext(DbContextOptions options)
: base(options)
{
}
public DbSet<NotificationTemplates> NotificationTemplates { get; set; } public DbSet<NotificationTemplates> NotificationTemplates { 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; }
public DbSet<EmbyEpisode> EmbyEpisode { get; set; }
public DbSet<MovieRequests> MovieRequests { get; set; } public DbSet<MovieRequests> MovieRequests { get; set; }
public DbSet<AlbumRequest> AlbumRequests { get; set; } public DbSet<AlbumRequest> AlbumRequests { get; set; }
@ -51,44 +48,11 @@ namespace Ombi.Store.Context
public DbSet<Audit> Audit { get; set; } public DbSet<Audit> Audit { get; set; }
public DbSet<Tokens> Tokens { get; set; } public DbSet<Tokens> Tokens { 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; }
public DbSet<RequestSubscription> RequestSubscription { get; set; } public DbSet<RequestSubscription> RequestSubscription { get; set; }
public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; } public DbSet<UserNotificationPreferences> UserNotificationPreferences { get; set; }
public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; } public DbSet<UserQualityProfiles> UserQualityProfileses { get; set; }
public DbSet<RequestQueue> RequestQueue { get; set; } public DbSet<RequestQueue> RequestQueue { 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, "Ombi.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() public void Seed()
{ {

View file

@ -1,39 +1,34 @@
using System.IO; using System.Linq;
using System.Linq;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Ombi.Helpers;
using Ombi.Store.Entities; using Ombi.Store.Entities;
namespace Ombi.Store.Context namespace Ombi.Store.Context
{ {
public sealed class SettingsContext : DbContext, ISettingsContext public abstract class SettingsContext : DbContext
{ {
private static bool _created; protected SettingsContext(DbContextOptions<SettingsContext> options) : base(options)
public SettingsContext()
{ {
if (_created) return;
_created = true;
Database.SetCommandTimeout(60);
Database.Migrate();
} }
/// <summary>
/// This allows a sub class to call the base class 'DbContext' non typed constructor
/// This is need because instances of the subclasses will use a specific typed DbContextOptions
/// which can not be converted into the parameter in the above constructor
/// </summary>
/// <param name="options"></param>
protected SettingsContext(DbContextOptions options)
: base(options)
{
}
public DbSet<GlobalSettings> Settings { get; set; } public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<ApplicationConfiguration> ApplicationConfigurations { 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() public void Seed()
{ {
using (var tran = Database.BeginTransaction()) using (var tran = Database.BeginTransaction())
{ {
// Add the tokens // Add the tokens

View file

@ -0,0 +1,36 @@
using System;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class ExternalSqliteContext : ExternalContext
{
private static bool _created;
public ExternalSqliteContext(DbContextOptions<ExternalSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191103205133_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class OmbiSqliteContext : OmbiContext
{
private static bool _created;
public OmbiSqliteContext(DbContextOptions<OmbiSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191102235658_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore;
namespace Ombi.Store.Context.Sqlite
{
public sealed class SettingsSqliteContext : SettingsContext
{
private static bool _created;
public SettingsSqliteContext(DbContextOptions<SettingsSqliteContext> options) : base(options)
{
if (_created) return;
_created = true;
Upgrade();
Database.SetCommandTimeout(60);
Database.Migrate();
}
private void Upgrade()
{
try
{
Database.ExecuteSqlCommand(@"INSERT INTO __EFMigrationsHistory (MigrationId,ProductVersion)
VALUES('20191103205204_Inital', '2.2.6-servicing-10079'); ");
}
catch (Exception)
{
// ignored
}
}
}
}

View file

@ -1 +1,3 @@
dotnet ef migrations add Inital --context OmbiContext --startup-project ../Ombi/Ombi.csproj dotnet ef migrations add Inital --context OmbiSqliteContext --startup-project ../Ombi/Ombi.csproj
If running migrations for any db provider other than Sqlite, then ensure the database.json is pointing at the correct DB type

View file

@ -0,0 +1,314 @@
// <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("20191018225833_PlexContentId")]
partial class PlexContentId
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.2-servicing-10034");
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<int?>("RequestId");
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
}
}
}

View file

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.External
{
public partial class PlexContentId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "RequestId",
table: "PlexServerContent",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RequestId",
table: "PlexServerContent");
}
}
}

View file

@ -14,7 +14,7 @@ namespace Ombi.Store.Migrations.External
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); .HasAnnotation("ProductVersion", "2.2.2-servicing-10034");
modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b => modelBuilder.Entity("Ombi.Store.Entities.CouchPotatoCache", b =>
{ {
@ -194,6 +194,8 @@ namespace Ombi.Store.Migrations.External
b.Property<string>("ReleaseYear"); b.Property<string>("ReleaseYear");
b.Property<int?>("RequestId");
b.Property<string>("TheMovieDbId"); b.Property<string>("TheMovieDbId");
b.Property<string>("Title"); b.Property<string>("Title");

View file

@ -0,0 +1,315 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.ExternalMySql
{
[DbContext(typeof(ExternalMySqlContext))]
[Migration("20191103213915_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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<int?>("RequestId");
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
}
}
}

View file

@ -0,0 +1,310 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.ExternalMySql
{
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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),
RequestId = table.Column<int>(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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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");
}
}
}

View file

@ -0,0 +1,313 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.ExternalMySql
{
[DbContext(typeof(ExternalMySqlContext))]
partial class ExternalMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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<int?>("RequestId");
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
}
}
}

View file

@ -0,0 +1,314 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.ExternalSqlite
{
[DbContext(typeof(ExternalSqliteContext))]
[Migration("20191103205133_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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<int?>("RequestId");
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
}
}
}

View file

@ -0,0 +1,309 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.ExternalSqlite
{
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),
RequestId = table.Column<int>(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");
}
}
}

View file

@ -0,0 +1,314 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.ExternalSqlite
{
[DbContext(typeof(ExternalSqliteContext))]
[Migration("20191113213617_RequestIdPatch")]
partial class RequestIdPatch
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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<int?>("RequestId");
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
}
}
}

View file

@ -0,0 +1,22 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.ExternalSqlite
{
public partial class RequestIdPatch : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.AddColumn<int>(
// name: "RequestId",
// table: "PlexServerContent",
// nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View file

@ -0,0 +1,312 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.Sqlite;
namespace Ombi.Store.Migrations.ExternalSqlite
{
[DbContext(typeof(ExternalSqliteContext))]
partial class ExternalSqliteContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
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<int?>("RequestId");
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
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,884 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.OmbiMySql
{
public partial class Inital : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
Alias = table.Column<string>(nullable: true),
UserType = table.Column<int>(nullable: false),
ProviderUserId = table.Column<string>(nullable: true),
LastLoggedIn = table.Column<DateTime>(nullable: true),
EmbyConnectUserId = table.Column<string>(nullable: true),
MovieRequestLimit = table.Column<int>(nullable: true),
EpisodeRequestLimit = table.Column<int>(nullable: true),
MusicRequestLimit = table.Column<int>(nullable: true),
UserAccessToken = table.Column<string>(nullable: true),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Audit",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DateTime = table.Column<DateTime>(nullable: false),
Description = table.Column<string>(nullable: true),
AuditType = table.Column<int>(nullable: false),
AuditArea = table.Column<int>(nullable: false),
User = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Audit", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IssueCategory",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IssueCategory", x => x.Id);
});
migrationBuilder.CreateTable(
name: "NotificationTemplates",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
NotificationType = table.Column<int>(nullable: false),
Agent = table.Column<int>(nullable: false),
Subject = table.Column<string>(nullable: true),
Message = table.Column<string>(nullable: true),
Enabled = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NotificationTemplates", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RecentlyAddedLog",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Type = table.Column<int>(nullable: false),
ContentType = table.Column<int>(nullable: false),
ContentId = table.Column<int>(nullable: false),
EpisodeNumber = table.Column<int>(nullable: true),
SeasonNumber = table.Column<int>(nullable: true),
AlbumId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RecentlyAddedLog", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RequestQueue",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RequestId = table.Column<int>(nullable: false),
Type = table.Column<int>(nullable: false),
Dts = table.Column<DateTime>(nullable: false),
Error = table.Column<string>(nullable: true),
Completed = table.Column<DateTime>(nullable: true),
RetryCount = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestQueue", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TvRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TvDbId = table.Column<int>(nullable: false),
ImdbId = table.Column<string>(nullable: true),
QualityOverride = table.Column<int>(nullable: true),
RootFolder = table.Column<int>(nullable: true),
Overview = table.Column<string>(nullable: true),
Title = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
Background = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
Status = table.Column<string>(nullable: true),
TotalSeasons = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TvRequests", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AlbumRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ForeignAlbumId = table.Column<string>(nullable: true),
ForeignArtistId = table.Column<string>(nullable: true),
Disk = table.Column<string>(nullable: true),
Cover = table.Column<string>(nullable: true),
Rating = table.Column<decimal>(nullable: false),
ReleaseDate = table.Column<DateTime>(nullable: false),
ArtistName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AlbumRequests", x => x.Id);
table.ForeignKey(
name: "FK_AlbumRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(nullable: false),
ProviderKey = table.Column<string>(nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MovieRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ImdbId = table.Column<string>(nullable: true),
Overview = table.Column<string>(nullable: true),
PosterPath = table.Column<string>(nullable: true),
ReleaseDate = table.Column<DateTime>(nullable: false),
DigitalReleaseDate = table.Column<DateTime>(nullable: true),
Status = table.Column<string>(nullable: true),
Background = table.Column<string>(nullable: true),
TheMovieDbId = table.Column<int>(nullable: false),
IssueId = table.Column<int>(nullable: true),
RootPathOverride = table.Column<int>(nullable: false),
QualityOverride = table.Column<int>(nullable: false),
LangCode = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MovieRequests", x => x.Id);
table.ForeignKey(
name: "FK_MovieRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "NotificationUserId",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PlayerId = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true),
AddedAt = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_NotificationUserId", x => x.Id);
table.ForeignKey(
name: "FK_NotificationUserId_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RequestLog",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestDate = table.Column<DateTime>(nullable: false),
RequestId = table.Column<int>(nullable: false),
EpisodeCount = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestLog", x => x.Id);
table.ForeignKey(
name: "FK_RequestLog_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RequestSubscription",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
RequestId = table.Column<int>(nullable: false),
RequestType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RequestSubscription", x => x.Id);
table.ForeignKey(
name: "FK_RequestSubscription_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Tokens",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Token = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Tokens", x => x.Id);
table.ForeignKey(
name: "FK_Tokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserNotificationPreferences",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
Agent = table.Column<int>(nullable: false),
Enabled = table.Column<bool>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UserNotificationPreferences", x => x.Id);
table.ForeignKey(
name: "FK_UserNotificationPreferences_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "UserQualityProfiles",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
SonarrQualityProfileAnime = table.Column<int>(nullable: false),
SonarrRootPathAnime = table.Column<int>(nullable: false),
SonarrRootPath = table.Column<int>(nullable: false),
SonarrQualityProfile = table.Column<int>(nullable: false),
RadarrRootPath = table.Column<int>(nullable: false),
RadarrQualityProfile = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserQualityProfiles", x => x.Id);
table.ForeignKey(
name: "FK_UserQualityProfiles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Votes",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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.CreateTable(
name: "ChildRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
Approved = table.Column<bool>(nullable: false),
MarkedAsApproved = table.Column<DateTime>(nullable: false),
RequestedDate = table.Column<DateTime>(nullable: false),
Available = table.Column<bool>(nullable: false),
MarkedAsAvailable = table.Column<DateTime>(nullable: true),
RequestedUserId = table.Column<string>(nullable: true),
Denied = table.Column<bool>(nullable: true),
MarkedAsDenied = table.Column<DateTime>(nullable: false),
DeniedReason = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
RequestedByAlias = table.Column<string>(nullable: true),
ParentRequestId = table.Column<int>(nullable: false),
IssueId = table.Column<int>(nullable: true),
SeriesType = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChildRequests", x => x.Id);
table.ForeignKey(
name: "FK_ChildRequests_TvRequests_ParentRequestId",
column: x => x.ParentRequestId,
principalTable: "TvRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChildRequests_AspNetUsers_RequestedUserId",
column: x => x.RequestedUserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Issues",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Title = table.Column<string>(nullable: true),
RequestType = table.Column<int>(nullable: false),
ProviderId = table.Column<string>(nullable: true),
RequestId = table.Column<int>(nullable: true),
Subject = table.Column<string>(nullable: true),
Description = table.Column<string>(nullable: true),
IssueCategoryId = table.Column<int>(nullable: false),
Status = table.Column<int>(nullable: false),
ResovledDate = table.Column<DateTime>(nullable: true),
UserReportedId = table.Column<string>(nullable: true),
IssueId = table.Column<int>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Issues", x => x.Id);
table.ForeignKey(
name: "FK_Issues_IssueCategory_IssueCategoryId",
column: x => x.IssueCategoryId,
principalTable: "IssueCategory",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Issues_ChildRequests_IssueId",
column: x => x.IssueId,
principalTable: "ChildRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Issues_MovieRequests_IssueId",
column: x => x.IssueId,
principalTable: "MovieRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Issues_AspNetUsers_UserReportedId",
column: x => x.UserReportedId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "SeasonRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
SeasonNumber = table.Column<int>(nullable: false),
ChildRequestId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SeasonRequests", x => x.Id);
table.ForeignKey(
name: "FK_SeasonRequests_ChildRequests_ChildRequestId",
column: x => x.ChildRequestId,
principalTable: "ChildRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IssueComments",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(nullable: true),
Comment = table.Column<string>(nullable: true),
IssuesId = table.Column<int>(nullable: true),
Date = table.Column<DateTime>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IssueComments", x => x.Id);
table.ForeignKey(
name: "FK_IssueComments_Issues_IssuesId",
column: x => x.IssuesId,
principalTable: "Issues",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_IssueComments_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "EpisodeRequests",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
EpisodeNumber = table.Column<int>(nullable: false),
Title = table.Column<string>(nullable: true),
AirDate = table.Column<DateTime>(nullable: false),
Url = table.Column<string>(nullable: true),
Available = table.Column<bool>(nullable: false),
Approved = table.Column<bool>(nullable: false),
Requested = table.Column<bool>(nullable: false),
SeasonId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EpisodeRequests", x => x.Id);
table.ForeignKey(
name: "FK_EpisodeRequests_SeasonRequests_SeasonId",
column: x => x.SeasonId,
principalTable: "SeasonRequests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AlbumRequests_RequestedUserId",
table: "AlbumRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ChildRequests_ParentRequestId",
table: "ChildRequests",
column: "ParentRequestId");
migrationBuilder.CreateIndex(
name: "IX_ChildRequests_RequestedUserId",
table: "ChildRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_EpisodeRequests_SeasonId",
table: "EpisodeRequests",
column: "SeasonId");
migrationBuilder.CreateIndex(
name: "IX_IssueComments_IssuesId",
table: "IssueComments",
column: "IssuesId");
migrationBuilder.CreateIndex(
name: "IX_IssueComments_UserId",
table: "IssueComments",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Issues_IssueCategoryId",
table: "Issues",
column: "IssueCategoryId");
migrationBuilder.CreateIndex(
name: "IX_Issues_IssueId",
table: "Issues",
column: "IssueId");
migrationBuilder.CreateIndex(
name: "IX_Issues_UserReportedId",
table: "Issues",
column: "UserReportedId");
migrationBuilder.CreateIndex(
name: "IX_MovieRequests_RequestedUserId",
table: "MovieRequests",
column: "RequestedUserId");
migrationBuilder.CreateIndex(
name: "IX_NotificationUserId_UserId",
table: "NotificationUserId",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RequestLog_UserId",
table: "RequestLog",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_RequestSubscription_UserId",
table: "RequestSubscription",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_SeasonRequests_ChildRequestId",
table: "SeasonRequests",
column: "ChildRequestId");
migrationBuilder.CreateIndex(
name: "IX_Tokens_UserId",
table: "Tokens",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserNotificationPreferences_UserId",
table: "UserNotificationPreferences",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_UserQualityProfiles_UserId",
table: "UserQualityProfiles",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Votes_UserId",
table: "Votes",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AlbumRequests");
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "Audit");
migrationBuilder.DropTable(
name: "EpisodeRequests");
migrationBuilder.DropTable(
name: "IssueComments");
migrationBuilder.DropTable(
name: "NotificationTemplates");
migrationBuilder.DropTable(
name: "NotificationUserId");
migrationBuilder.DropTable(
name: "RecentlyAddedLog");
migrationBuilder.DropTable(
name: "RequestLog");
migrationBuilder.DropTable(
name: "RequestQueue");
migrationBuilder.DropTable(
name: "RequestSubscription");
migrationBuilder.DropTable(
name: "Tokens");
migrationBuilder.DropTable(
name: "UserNotificationPreferences");
migrationBuilder.DropTable(
name: "UserQualityProfiles");
migrationBuilder.DropTable(
name: "Votes");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "SeasonRequests");
migrationBuilder.DropTable(
name: "Issues");
migrationBuilder.DropTable(
name: "PlexServerContent");
migrationBuilder.DropTable(
name: "IssueCategory");
migrationBuilder.DropTable(
name: "ChildRequests");
migrationBuilder.DropTable(
name: "MovieRequests");
migrationBuilder.DropTable(
name: "TvRequests");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}

View file

@ -0,0 +1,897 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.OmbiMySql
{
[DbContext(typeof(OmbiMySqlContext))]
partial class OmbiMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Ombi.Store.Entities.Audit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AuditArea");
b.Property<int>("AuditType");
b.Property<DateTime>("DateTime");
b.Property<string>("Description");
b.Property<string>("User");
b.HasKey("Id");
b.ToTable("Audit");
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationTemplates", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Agent");
b.Property<bool>("Enabled");
b.Property<string>("Message");
b.Property<int>("NotificationType");
b.Property<string>("Subject");
b.HasKey("Id");
b.ToTable("NotificationTemplates");
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AddedAt");
b.Property<string>("PlayerId");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("NotificationUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.OmbiUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("Alias");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("EmbyConnectUserId");
b.Property<int?>("EpisodeRequestLimit");
b.Property<DateTime?>("LastLoggedIn");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<int?>("MovieRequestLimit");
b.Property<int?>("MusicRequestLimit");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("ProviderUserId");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserAccessToken");
b.Property<string>("UserName")
.HasMaxLength(256);
b.Property<int>("UserType");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Ombi.Store.Entities.RecentlyAddedLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AddedAt");
b.Property<string>("AlbumId");
b.Property<int>("ContentId");
b.Property<int>("ContentType");
b.Property<int?>("EpisodeNumber");
b.Property<int?>("SeasonNumber");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("RecentlyAddedLog");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestQueue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime?>("Completed");
b.Property<DateTime>("Dts");
b.Property<string>("Error");
b.Property<int>("RequestId");
b.Property<int>("RetryCount");
b.Property<int>("Type");
b.HasKey("Id");
b.ToTable("RequestQueue");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("RequestId");
b.Property<int>("RequestType");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("RequestSubscription");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<string>("ArtistName");
b.Property<bool>("Available");
b.Property<string>("Cover");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<string>("Disk");
b.Property<string>("ForeignAlbumId");
b.Property<string>("ForeignArtistId");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<decimal>("Rating");
b.Property<DateTime>("ReleaseDate");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("RequestedUserId");
b.ToTable("AlbumRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<int?>("IssueId");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<int>("ParentRequestId");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<int>("SeriesType");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("ParentRequestId");
b.HasIndex("RequestedUserId");
b.ToTable("ChildRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueCategory", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Value");
b.HasKey("Id");
b.ToTable("IssueCategory");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Comment");
b.Property<DateTime>("Date");
b.Property<int?>("IssuesId");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("IssuesId");
b.HasIndex("UserId");
b.ToTable("IssueComments");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<int>("IssueCategoryId");
b.Property<int?>("IssueId");
b.Property<string>("ProviderId");
b.Property<int?>("RequestId");
b.Property<int>("RequestType");
b.Property<DateTime?>("ResovledDate");
b.Property<int>("Status");
b.Property<string>("Subject");
b.Property<string>("Title");
b.Property<string>("UserReportedId");
b.HasKey("Id");
b.HasIndex("IssueCategoryId");
b.HasIndex("IssueId");
b.HasIndex("UserReportedId");
b.ToTable("Issues");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<string>("Background");
b.Property<bool?>("Denied");
b.Property<string>("DeniedReason");
b.Property<DateTime?>("DigitalReleaseDate");
b.Property<string>("ImdbId");
b.Property<int?>("IssueId");
b.Property<string>("LangCode");
b.Property<DateTime>("MarkedAsApproved");
b.Property<DateTime?>("MarkedAsAvailable");
b.Property<DateTime>("MarkedAsDenied");
b.Property<string>("Overview");
b.Property<string>("PosterPath");
b.Property<int>("QualityOverride");
b.Property<DateTime>("ReleaseDate");
b.Property<int>("RequestType");
b.Property<string>("RequestedByAlias");
b.Property<DateTime>("RequestedDate");
b.Property<string>("RequestedUserId");
b.Property<int>("RootPathOverride");
b.Property<string>("Status");
b.Property<int>("TheMovieDbId");
b.Property<string>("Title");
b.HasKey("Id");
b.HasIndex("RequestedUserId");
b.ToTable("MovieRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EpisodeCount");
b.Property<DateTime>("RequestDate");
b.Property<int>("RequestId");
b.Property<int>("RequestType");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("RequestLog");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.TvRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Background");
b.Property<string>("ImdbId");
b.Property<string>("Overview");
b.Property<string>("PosterPath");
b.Property<int?>("QualityOverride");
b.Property<DateTime>("ReleaseDate");
b.Property<int?>("RootFolder");
b.Property<string>("Status");
b.Property<string>("Title");
b.Property<int>("TotalSeasons");
b.Property<int>("TvDbId");
b.HasKey("Id");
b.ToTable("TvRequests");
});
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Token");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Tokens");
});
modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Agent");
b.Property<bool>("Enabled");
b.Property<string>("UserId");
b.Property<string>("Value");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserNotificationPreferences");
});
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("RadarrQualityProfile");
b.Property<int>("RadarrRootPath");
b.Property<int>("SonarrQualityProfile");
b.Property<int>("SonarrQualityProfileAnime");
b.Property<int>("SonarrRootPath");
b.Property<int>("SonarrRootPathAnime");
b.Property<string>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
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")
.ValueGeneratedOnAdd();
b.Property<DateTime>("AirDate");
b.Property<bool>("Approved");
b.Property<bool>("Available");
b.Property<int>("EpisodeNumber");
b.Property<bool>("Requested");
b.Property<int>("SeasonId");
b.Property<string>("Title");
b.Property<string>("Url");
b.HasKey("Id");
b.HasIndex("SeasonId");
b.ToTable("EpisodeRequests");
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ChildRequestId");
b.Property<int>("SeasonNumber");
b.HasKey("Id");
b.HasIndex("ChildRequestId");
b.ToTable("SeasonRequests");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Entities.NotificationUserId", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany("NotificationUserIds")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.RequestSubscription", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.AlbumRequest", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.ChildRequests", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.TvRequests", "ParentRequest")
.WithMany("ChildRequests")
.HasForeignKey("ParentRequestId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.IssueComments", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.Issues", "Issues")
.WithMany("Comments")
.HasForeignKey("IssuesId");
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.Issues", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.IssueCategory", "IssueCategory")
.WithMany()
.HasForeignKey("IssueCategoryId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Ombi.Store.Entities.Requests.ChildRequests")
.WithMany("Issues")
.HasForeignKey("IssueId");
b.HasOne("Ombi.Store.Entities.Requests.MovieRequests")
.WithMany("Issues")
.HasForeignKey("IssueId");
b.HasOne("Ombi.Store.Entities.OmbiUser", "UserReported")
.WithMany()
.HasForeignKey("UserReportedId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.MovieRequests", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "RequestedUser")
.WithMany()
.HasForeignKey("RequestedUserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Requests.RequestLog", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.Tokens", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.UserNotificationPreferences", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany("UserNotificationPreferences")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Ombi.Store.Entities.UserQualityProfiles", b =>
{
b.HasOne("Ombi.Store.Entities.OmbiUser", "User")
.WithMany()
.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")
.WithMany("Episodes")
.HasForeignKey("SeasonId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Ombi.Store.Repository.Requests.SeasonRequests", b =>
{
b.HasOne("Ombi.Store.Entities.Requests.ChildRequests", "ChildRequest")
.WithMany("SeasonRequests")
.HasForeignKey("ChildRequestId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,51 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.SettingsMySql
{
[DbContext(typeof(SettingsMySqlContext))]
[Migration("20191103205915_Inital")]
partial class Inital
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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
}
}
}

View file

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Ombi.Store.Migrations.SettingsMySql
{
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
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");
}
}
}

View file

@ -0,0 +1,49 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Ombi.Store.Context.MySql;
namespace Ombi.Store.Migrations.SettingsMySql
{
[DbContext(typeof(SettingsMySqlContext))]
partial class SettingsMySqlContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
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
}
}
}

Some files were not shown because too many files have changed in this diff Show more