diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml
index 47917439c..07f8a1a2b 100644
--- a/.github/workflows/chromatic.yml
+++ b/.github/workflows/chromatic.yml
@@ -37,7 +37,7 @@ jobs:
exitOnceUploaded: true
- name: Publish to Chromatic and auto accept changes
- if: github.ref == 'refs/heads/master'
+ if: github.ref == 'refs/heads/develop'
uses: chromaui/action@v1
with:
projectToken: 7c47e1a1a4bd
diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml
index 9101bdb60..2dc51179e 100644
--- a/.github/workflows/cypress.yml
+++ b/.github/workflows/cypress.yml
@@ -34,16 +34,28 @@ jobs:
- name: Install Frontend Deps
run: yarn --cwd ./src/Ombi/ClientApp install
- - name: Start Frontend
- run: |
- nohup yarn --cwd ./src/Ombi/ClientApp start &
+ - name: Build Frontend
+ run: yarn --cwd ./src/Ombi/ClientApp build
- - name: Install Automation Deps
- run: yarn --cwd ./tests install
+ - name: Build Docker Image
+ run: docker build -t ombi src/
- - name: Start Backend
- run: |
- nohup dotnet run --project ./src/Ombi -- --host http://*:3577 &
+ - name: Run Docker Image
+ run: nohup docker run --rm -p 5000:5000 ombi &
+
+ - name: Sleep for server to start
+ run: sleep 20
+
+ # - name: Start Frontend
+ # run: |
+ # nohup yarn --cwd ./src/Ombi/ClientApp start &
+
+ # - name: Install Automation Deps
+ # run: yarn --cwd ./tests install
+
+ # - name: Start Backend
+ # run: |
+ # nohup dotnet run --project ./src/Ombi -- --host http://*:3577 &
- name: Cypress Tests
uses: cypress-io/github-action@v2.8.2
@@ -52,9 +64,9 @@ jobs:
browser: chrome
headless: true
working-directory: tests
- wait-on: http://localhost:3577/
+ wait-on: http://localhost:5000/
# 10 minutes
wait-on-timeout: 600
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63ab88463..4de0fb2ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,145 @@
+## [4.27.6](https://github.com/Ombi-app/Ombi/compare/v4.27.5...v4.27.6) (2022-10-01)
+
+
+### Bug Fixes
+
+* **notifications:** Fixed the error when sending multiple test notifications. Added more logging when Discord complains the message is invalid ([fc14780](https://github.com/Ombi-app/Ombi/commit/fc14780bd354483119ddcbb55a8c382e1890a783))
+
+
+
+## [4.27.5](https://github.com/Ombi-app/Ombi/compare/v4.27.4...v4.27.5) (2022-09-30)
+
+
+### Bug Fixes
+
+* **importer:** 🐛 Allow you to only import Plex Admins without the Plex Users ([8c9ad9b](https://github.com/Ombi-app/Ombi/commit/8c9ad9b414fdc6c88bdb911d6057ae5d38783b98))
+
+
+
+## [4.27.4](https://github.com/Ombi-app/Ombi/compare/v4.27.3...v4.27.4) (2022-09-30)
+
+
+
+## [4.27.3](https://github.com/Ombi-app/Ombi/compare/v4.27.2...v4.27.3) (2022-09-30)
+
+
+### Bug Fixes
+
+* **availability:** 🐛 Fixed a issue with the availability checker after the previous update. Added full test coverage around that area ([28e2480](https://github.com/Ombi-app/Ombi/commit/28e248046ad56390595f84172bbd5f5961325b4d))
+
+
+
+## [4.27.2](https://github.com/Ombi-app/Ombi/compare/v4.27.1...v4.27.2) (2022-09-29)
+
+
+### Bug Fixes
+
+* **sonarr:** :bug: Cleaned up and removed Sonarr v3 option, sonarr v3 is now the default. This allows us to get ready for the upcoming Sonarr v4 ([#4764](https://github.com/Ombi-app/Ombi/issues/4764)) ([2cddec7](https://github.com/Ombi-app/Ombi/commit/2cddec759004b6490f686ff74cb092238e3dc946))
+
+
+
+## [4.27.1](https://github.com/Ombi-app/Ombi/compare/v4.27.0...v4.27.1) (2022-09-20)
+
+
+### Bug Fixes
+
+* **plex:** stop the plex sync from deleting episodes when we can't find the plex key ([66b05e5](https://github.com/Ombi-app/Ombi/commit/66b05e5a85dbfe1fec5f9366e80987f2cfa1f4fe))
+
+
+
+# [4.27.0](https://github.com/Ombi-app/Ombi/compare/v4.26.0...v4.27.0) (2022-09-14)
+
+
+### Features
+
+* Recently requested improvements ([#4755](https://github.com/Ombi-app/Ombi/issues/4755)) ([ff04d87](https://github.com/Ombi-app/Ombi/commit/ff04d875343604c77c391bf55d0968977e480281))
+
+
+
+# [4.26.0](https://github.com/Ombi-app/Ombi/compare/v4.25.1...v4.26.0) (2022-09-07)
+
+
+### Features
+
+* **notifications:** Add more curly variables for partially available notification ([66aa101](https://github.com/Ombi-app/Ombi/commit/66aa101019c4c4b34e186db9d303049d02b9c781))
+
+
+
+## [4.25.1](https://github.com/Ombi-app/Ombi/compare/v4.25.0...v4.25.1) (2022-09-07)
+
+
+### Bug Fixes
+
+* **webhook:** Remove added trailing slash from webhook URL [#4710](https://github.com/Ombi-app/Ombi/issues/4710) ([369eb33](https://github.com/Ombi-app/Ombi/commit/369eb339171671101be219486e2aab27a20f3d74))
+
+
+
+# [4.25.0](https://github.com/Ombi-app/Ombi/compare/v4.24.0...v4.25.0) (2022-08-23)
+
+
+### Bug Fixes
+
+* fixed stats controller ([#4742](https://github.com/Ombi-app/Ombi/issues/4742)) ([47ea64b](https://github.com/Ombi-app/Ombi/commit/47ea64b5a401770f1943b575ca40f84d515e96b3))
+
+
+### Features
+
+* Watchlist history errors([#4741](https://github.com/Ombi-app/Ombi/issues/4741)) ([c222f1a](https://github.com/Ombi-app/Ombi/commit/c222f1a945e944ef34e68cad2b61f40e57cab823))
+
+
+
+# [4.24.0](https://github.com/Ombi-app/Ombi/compare/v4.23.2...v4.24.0) (2022-08-22)
+
+
+### Features
+
+* add crew on movie page ([#4722](https://github.com/Ombi-app/Ombi/issues/4722)) ([1d53261](https://github.com/Ombi-app/Ombi/commit/1d532613823804b25984bd1d223d081a54ad143d))
+
+
+
+## [4.23.2](https://github.com/Ombi-app/Ombi/compare/v4.23.1...v4.23.2) (2022-08-22)
+
+
+### Bug Fixes
+
+* Fix conflicting property name for Swagger ([#4733](https://github.com/Ombi-app/Ombi/issues/4733)) ([d661f32](https://github.com/Ombi-app/Ombi/commit/d661f32e8a9e105faab6380b4b7b642896b98163))
+
+
+
+## [4.23.1](https://github.com/Ombi-app/Ombi/compare/v4.23.0...v4.23.1) (2022-08-12)
+
+
+### Bug Fixes
+
+* Localize recently requested on discover page ([#4729](https://github.com/Ombi-app/Ombi/issues/4729)) ([bf65c76](https://github.com/Ombi-app/Ombi/commit/bf65c76ff9ce38f65a9e5feb872734e8d8e35eb6))
+
+
+
+# [4.23.0](https://github.com/Ombi-app/Ombi/compare/v4.22.4...v4.23.0) (2022-08-09)
+
+
+### Bug Fixes
+
+* Log Microsoft warnings to log file ([#4723](https://github.com/Ombi-app/Ombi/issues/4723)) ([26ac75f](https://github.com/Ombi-app/Ombi/commit/26ac75f0c223c2a91e3471797ae46ede3fde89cc))
+
+
+### Features
+
+* ✨ Recently Requested on Discover Page ([#4387](https://github.com/Ombi-app/Ombi/issues/4387)) ([44d38fb](https://github.com/Ombi-app/Ombi/commit/44d38fbaae521dbb467b61c7471b2384015ac52e))
+
+
+
+## [4.22.4](https://github.com/Ombi-app/Ombi/compare/v4.22.3...v4.22.4) (2022-08-04)
+
+
+### Bug Fixes
+
+* :bug: Fixed missing externals ([#4712](https://github.com/Ombi-app/Ombi/issues/4712)) ([fcc1eaa](https://github.com/Ombi-app/Ombi/commit/fcc1eaaa377683dcdc81d62a2a688fb0c4490c7b))
+* fixed trakt image not loading when base url present ([#4711](https://github.com/Ombi-app/Ombi/issues/4711)) ([f102dcf](https://github.com/Ombi-app/Ombi/commit/f102dcf751c2eb62ebfe30f9f8e4b2ad863c3b0d))
+* **translations:** 🌐 New translations from Crowdin [skip ci] ([#4713](https://github.com/Ombi-app/Ombi/issues/4713)) ([ff142b0](https://github.com/Ombi-app/Ombi/commit/ff142b09abbb2f9540387284222552e6e12639fe))
+
+
+
## [4.22.3](https://github.com/Ombi-app/Ombi/compare/v4.22.2...v4.22.3) (2022-07-28)
@@ -264,98 +406,3 @@
-## [4.16.8](https://github.com/Ombi-app/Ombi/compare/v4.16.7...v4.16.8) (2022-04-13)
-
-
-### Bug Fixes
-
-* **availability:** Fixed an issue where we wouldn't mark a available 4k movie as available (when 4K request feature is disabled) ([b492699](https://github.com/Ombi-app/Ombi/commit/b49269961d4830a530e3054976a47f519524948b))
-
-
-
-## [4.16.7](https://github.com/Ombi-app/Ombi/compare/v4.16.6...v4.16.7) (2022-04-12)
-
-
-
-## [4.16.6](https://github.com/Ombi-app/Ombi/compare/v4.16.5...v4.16.6) (2022-04-11)
-
-
-
-## [4.16.5](https://github.com/Ombi-app/Ombi/compare/v4.16.4...v4.16.5) (2022-04-08)
-
-
-### Bug Fixes
-
-* **watchlist:** actually fixed it this time... ([d962a32](https://github.com/Ombi-app/Ombi/commit/d962a3211eca29520662ddce962676e3aea17ec5))
-
-
-
-## [4.16.4](https://github.com/Ombi-app/Ombi/compare/v4.16.3...v4.16.4) (2022-04-08)
-
-
-
-## [4.16.3](https://github.com/Ombi-app/Ombi/compare/v4.16.2...v4.16.3) (2022-04-08)
-
-
-### Bug Fixes
-
-* **plex-watchlist:** :bug: Fixed the issue where the watchlist didn't work for users logging in via OAuth ([6398f6a](https://github.com/Ombi-app/Ombi/commit/6398f6a4f7755281ebeac537e3ff623df5cfa0f3))
-
-
-
-## [4.16.2](https://github.com/Ombi-app/Ombi/compare/v4.16.1...v4.16.2) (2022-04-07)
-
-
-### Bug Fixes
-
-* **wizard:** Fixed an issue when using Plex OAuth it could fail setting up ([b743cf4](https://github.com/Ombi-app/Ombi/commit/b743cf4fafa7341ad1b163276f006d7ab0e9dcff))
-
-
-
-## [4.16.1](https://github.com/Ombi-app/Ombi/compare/v4.16.0...v4.16.1) (2022-04-07)
-
-
-
-# [4.16.0](https://github.com/Ombi-app/Ombi/compare/v4.15.6...v4.16.0) (2022-04-07)
-
-
-
-## [4.15.6](https://github.com/Ombi-app/Ombi/compare/v4.15.5...v4.15.6) (2022-04-07)
-
-
-### Bug Fixes
-
-* **radarr:** Fixed an issue where we couldn't sync radarr content [#4577](https://github.com/Ombi-app/Ombi/issues/4577) ([a5355a3](https://github.com/Ombi-app/Ombi/commit/a5355a3023e6900c4dd1b0da4722d7596c03907f))
-
-
-
-## [4.15.5](https://github.com/Ombi-app/Ombi/compare/v4.15.4...v4.15.5) (2022-04-06)
-
-
-
-## [4.15.4](https://github.com/Ombi-app/Ombi/compare/v4.15.3...v4.15.4) (2022-03-29)
-
-
-
-## [4.15.3](https://github.com/Ombi-app/Ombi/compare/v4.15.2...v4.15.3) (2022-03-24)
-
-
-
-## [4.15.2](https://github.com/Ombi-app/Ombi/compare/v4.15.1...v4.15.2) (2022-03-23)
-
-
-### Bug Fixes
-
-* **metadata:** improved the metadata job to also lookup the media in Plex to see if it has any more uptodate metadata ([83d1a15](https://github.com/Ombi-app/Ombi/commit/83d1a15cc9d0ee91be73bd91c4672cf1bcf2728a))
-
-
-
-## [4.15.1](https://github.com/Ombi-app/Ombi/compare/v4.15.0...v4.15.1) (2022-03-18)
-
-
-### Bug Fixes
-
-* **mediaserver:** fixed an issue where we were not detecting available content correctly [#4542](https://github.com/Ombi-app/Ombi/issues/4542) ([9cdd6f4](https://github.com/Ombi-app/Ombi/commit/9cdd6f41cdab8825a984905c089611409c53c753))
-
-
-
diff --git a/README.md b/README.md
index f7b2e58ff..e54604cb4 100644
--- a/README.md
+++ b/README.md
@@ -515,6 +515,13 @@ Here are some of the features Ombi has:
Fish2
+
+
+
+
+ Hadrien
+
+ |
@@ -535,15 +542,15 @@ Here are some of the features Ombi has:
Imgbot
- |
+
+
Jacob Pyke
- |
-
+
@@ -578,15 +585,15 @@ Here are some of the features Ombi has:
Jono Cairns
- |
+
+
Kris Klosterman
- |
-
+
@@ -621,15 +628,15 @@ Here are some of the features Ombi has:
Marley
- |
+
+
Matt
- |
-
+
@@ -644,6 +651,13 @@ Here are some of the features Ombi has:
Micky
|
+
+
+
+
+ Miguel A Vico Moya
+
+ |
@@ -657,7 +671,8 @@ Here are some of the features Ombi has:
Qiming Chen
- |
+
+
@@ -671,8 +686,7 @@ Here are some of the features Ombi has:
Rob Gökemeijer
- |
-
+
@@ -700,7 +714,8 @@ Here are some of the features Ombi has:
Teifun2
- |
+
+
@@ -714,8 +729,7 @@ Here are some of the features Ombi has:
Tim Trott
- |
-
+
@@ -743,7 +757,8 @@ Here are some of the features Ombi has:
Xirg
- |
+
+
@@ -757,8 +772,7 @@ Here are some of the features Ombi has:
Blake Drumm
- |
-
+
@@ -786,7 +800,8 @@ Here are some of the features Ombi has:
Echel0n
- |
+
+
@@ -800,8 +815,7 @@ Here are some of the features Ombi has:
Maartenheebink
- |
-
+
@@ -809,6 +823,13 @@ Here are some of the features Ombi has:
Patrick Weber
|
+
+
+
+
+ Mkgeeky
+
+ |
@@ -822,7 +843,8 @@ Here are some of the features Ombi has:
Tdorsey
- |
+
+
diff --git a/src/.dockerignore b/src/.dockerignore
new file mode 100644
index 000000000..252736d92
--- /dev/null
+++ b/src/.dockerignore
@@ -0,0 +1,285 @@
+**/bin/
+**/obj/
+**/.angular/
+**/node_modules/
+.gitignore
+.git/
+
+
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+Properties/launchSettings.json
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/
+tools/Cake.CoreCLR
+.vscode
+tools
+.dotnet
+Dockerfile
+
+# .env file contains default environment variables for docker
+.env
+.git/
\ No newline at end of file
diff --git a/src/.idea/.idea.Ombi/.idea/contentModel.xml b/src/.idea/.idea.Ombi/.idea/contentModel.xml
index 438274536..ffc2d3ce6 100644
--- a/src/.idea/.idea.Ombi/.idea/contentModel.xml
+++ b/src/.idea/.idea.Ombi/.idea/contentModel.xml
@@ -268,6 +268,12 @@
+
+
+
+
+
+
diff --git a/src/Ombi.Api.Discord/DiscordApi.cs b/src/Ombi.Api.Discord/DiscordApi.cs
index 34342e559..122c51a87 100644
--- a/src/Ombi.Api.Discord/DiscordApi.cs
+++ b/src/Ombi.Api.Discord/DiscordApi.cs
@@ -1,4 +1,6 @@
-using System.Net.Http;
+using System;
+using System.Net;
+using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Ombi.Api.Discord.Models;
@@ -23,7 +25,20 @@ namespace Ombi.Api.Discord
request.ApplicationJsonContentType();
- await Api.Request(request);
+ var response = await Api.Request(request);
+
+ if (!response.IsSuccessStatusCode)
+ {
+ var content = await response.Content.ReadAsStringAsync();
+ throw new DiscordException(content, response.StatusCode);
+ }
+ }
+
+ public class DiscordException : Exception
+ {
+ public DiscordException(string content, HttpStatusCode code) : base($"Exception when calling Discord with status code {code} and message: {content}")
+ {
+ }
}
}
}
diff --git a/src/Ombi.Api.Lidarr/Models/ArtistAdd.cs b/src/Ombi.Api.Lidarr/Models/ArtistAdd.cs
index 27ff3f733..a53e8a78e 100644
--- a/src/Ombi.Api.Lidarr/Models/ArtistAdd.cs
+++ b/src/Ombi.Api.Lidarr/Models/ArtistAdd.cs
@@ -5,27 +5,16 @@ namespace Ombi.Api.Lidarr.Models
{
public class ArtistAdd
{
- public string status { get; set; }
- public bool ended { get; set; }
public string artistName { get; set; }
public string foreignArtistId { get; set; }
- public int tadbId { get; set; }
- public int discogsId { get; set; }
- public string overview { get; set; }
- public string disambiguation { get; set; }
public Link[] links { get; set; }
public Image[] images { get; set; }
- public string remotePoster { get; set; }
public int qualityProfileId { get; set; }
public int metadataProfileId { get; set; }
public bool albumFolder { get; set; }
public bool monitored { get; set; }
public string cleanName { get; set; }
- public string sortName { get; set; }
- public object[] tags { get; set; }
public DateTime added { get; set; }
- public Ratings ratings { get; set; }
- public Statistics statistics { get; set; }
public Addoptions addOptions { get; set; }
public string rootFolderPath { get; set; }
}
@@ -49,4 +38,4 @@ namespace Ombi.Api.Lidarr.Models
None,
Unknown
}
-}
\ No newline at end of file
+}
diff --git a/src/Ombi.Api.Plex/Models/Metadata.cs b/src/Ombi.Api.Plex/Models/Metadata.cs
index 97cab391b..d473e44f8 100644
--- a/src/Ombi.Api.Plex/Models/Metadata.cs
+++ b/src/Ombi.Api.Plex/Models/Metadata.cs
@@ -39,6 +39,7 @@ namespace Ombi.Api.Plex.Models
public string grandparentTheme { get; set; }
public string chapterSource { get; set; }
public Medium[] Media { get; set; }
+ [JsonProperty("Guid")] // force uppercase to solve conflict with lowercase guid
public List Guid { get; set; } = new List();
}
diff --git a/src/Ombi.Api.Plex/Models/PlexWatchlistContainer.cs b/src/Ombi.Api.Plex/Models/PlexWatchlistContainer.cs
index b208c189f..2eab1d255 100644
--- a/src/Ombi.Api.Plex/Models/PlexWatchlistContainer.cs
+++ b/src/Ombi.Api.Plex/Models/PlexWatchlistContainer.cs
@@ -1,9 +1,12 @@
using System.Collections.Generic;
+using System.Text.Json.Serialization;
namespace Ombi.Api.Plex.Models
{
public class PlexWatchlistContainer
{
public PlexWatchlist MediaContainer { get; set; }
+ [JsonIgnore]
+ public bool AuthError { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Ombi.Api.Plex/PlexApi.cs b/src/Ombi.Api.Plex/PlexApi.cs
index 9f91c540c..fae4a78b9 100644
--- a/src/Ombi.Api.Plex/PlexApi.cs
+++ b/src/Ombi.Api.Plex/PlexApi.cs
@@ -1,4 +1,5 @@
using System;
+using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -295,9 +296,18 @@ namespace Ombi.Api.Plex
var request = new Request("library/sections/watchlist/all", WatchlistUri, HttpMethod.Get);
await AddHeaders(request, plexToken);
- var result = await Api.Request(request, cancellationToken);
+ var result = await Api.Request(request, cancellationToken);
- return result;
+ if (result.StatusCode.Equals(HttpStatusCode.Unauthorized))
+ {
+ return new PlexWatchlistContainer
+ {
+ AuthError = true
+ };
+ }
+
+ var receivedString = await result.Content.ReadAsStringAsync(cancellationToken);
+ return JsonConvert.DeserializeObject(receivedString);
}
public async Task GetWatchlistMetadata(string ratingKey, string plexToken, CancellationToken cancellationToken)
diff --git a/src/Ombi.Api.Sonarr/Models/SonarrProfile.cs b/src/Ombi.Api.Sonarr/Models/SonarrProfile.cs
index 179459c43..51249d79b 100644
--- a/src/Ombi.Api.Sonarr/Models/SonarrProfile.cs
+++ b/src/Ombi.Api.Sonarr/Models/SonarrProfile.cs
@@ -5,8 +5,6 @@ namespace Ombi.Api.Sonarr.Models
public class SonarrProfile
{
public string name { get; set; }
- public Cutoff cutoff { get; set; }
- public List- items { get; set; }
public int id { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Ombi.Api.Webhook/WebhookApi.cs b/src/Ombi.Api.Webhook/WebhookApi.cs
index f2faaa18b..7a5d1d611 100644
--- a/src/Ombi.Api.Webhook/WebhookApi.cs
+++ b/src/Ombi.Api.Webhook/WebhookApi.cs
@@ -19,8 +19,8 @@ namespace Ombi.Api.Webhook
public async Task PushAsync(string baseUrl, string accessToken, IDictionary parameters)
{
- var request = new Request("", baseUrl, HttpMethod.Post);
-
+ var request = new Request("", baseUrl, HttpMethod.Post) {IgnoreBaseUrlAppend = true};
+
if (!string.IsNullOrWhiteSpace(accessToken))
{
request.AddHeader("Access-Token", accessToken);
diff --git a/src/Ombi.Core.Tests/Services/PlexServiceTests.cs b/src/Ombi.Core.Tests/Services/PlexServiceTests.cs
new file mode 100644
index 000000000..a61c86b2e
--- /dev/null
+++ b/src/Ombi.Core.Tests/Services/PlexServiceTests.cs
@@ -0,0 +1,146 @@
+using MockQueryable.Moq;
+using Moq.AutoMock;
+using NUnit.Framework;
+using Ombi.Core.Models;
+using Ombi.Core.Services;
+using Ombi.Store.Entities;
+using Ombi.Store.Repository;
+using Ombi.Test.Common;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using UserType = Ombi.Store.Entities.UserType;
+
+namespace Ombi.Core.Tests.Services
+{
+ public class PlexServiceTests
+ {
+
+ private PlexService _subject;
+ private AutoMocker _mocker;
+
+ [SetUp]
+ public void Setup()
+ {
+ _mocker = new AutoMocker();
+ _subject = _mocker.CreateInstance();
+ }
+
+ [Test]
+ public async Task GetWatchListUsers_AllUsersSynced()
+ {
+ var userMock = MockHelper.MockUserManager(new List
+ {
+ new OmbiUser
+ {
+ MediaServerToken = "token",
+ Id = "1",
+ UserName = "user1",
+ UserType = UserType.PlexUser,
+ },
+ new OmbiUser
+ {
+ MediaServerToken = "token",
+ Id = "2",
+ UserName = "user2",
+ UserType = UserType.PlexUser,
+ },
+ new OmbiUser
+ {
+ MediaServerToken = "token",
+ Id = "2",
+ UserName = "user2",
+ UserType = UserType.LocalUser,
+ }
+ });
+
+ _mocker.Use(userMock.Object);
+ _subject = _mocker.CreateInstance();
+
+ _mocker.Setup, IQueryable>(x => x.GetAll())
+ .Returns(new List().AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetWatchlistUsers(CancellationToken.None);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.All(x => x.SyncStatus == WatchlistSyncStatus.Successful));
+ Assert.That(result.Count, Is.EqualTo(2));
+ });
+ }
+
+ [Test]
+ public async Task GetWatchListUsers_NotEnabled()
+ {
+ var userMock = MockHelper.MockUserManager(new List
+ {
+ new OmbiUser
+ {
+ MediaServerToken = "",
+ Id = "1",
+ UserName = "user1",
+ UserType = UserType.PlexUser,
+ },
+ new OmbiUser
+ {
+ MediaServerToken = null,
+ Id = "2",
+ UserName = "user2",
+ UserType = UserType.PlexUser,
+ },
+ });
+
+ _mocker.Use(userMock.Object);
+ _subject = _mocker.CreateInstance();
+
+ _mocker.Setup, IQueryable>(x => x.GetAll())
+ .Returns(new List().AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetWatchlistUsers(CancellationToken.None);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.All(x => x.SyncStatus == WatchlistSyncStatus.NotEnabled));
+ Assert.That(result.Count, Is.EqualTo(2));
+ });
+ }
+
+
+ [Test]
+ public async Task GetWatchListUsers_Failed()
+ {
+ var userMock = MockHelper.MockUserManager(new List
+ {
+ new OmbiUser
+ {
+ MediaServerToken = "test",
+ Id = "1",
+ UserName = "user1",
+ UserType = UserType.PlexUser,
+ },
+ });
+
+ _mocker.Use(userMock.Object);
+ _subject = _mocker.CreateInstance();
+
+ _mocker.Setup, IQueryable>(x => x.GetAll())
+ .Returns(new List
+ {
+ new PlexWatchlistUserError
+ {
+ UserId = "1",
+ MediaServerToken = "test",
+ }
+ }.AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetWatchlistUsers(CancellationToken.None);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(result.All(x => x.SyncStatus == WatchlistSyncStatus.Failed));
+ Assert.That(result.Count, Is.EqualTo(1));
+ });
+ }
+ }
+}
diff --git a/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs b/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs
new file mode 100644
index 000000000..fd67e4e33
--- /dev/null
+++ b/src/Ombi.Core.Tests/Services/RecentlyRequestedServiceTests.cs
@@ -0,0 +1,202 @@
+using AutoFixture;
+using MockQueryable.Moq;
+using Moq;
+using Moq.AutoMock;
+using NUnit.Framework;
+using Ombi.Core.Authentication;
+using Ombi.Core.Helpers;
+using Ombi.Core.Models.Requests;
+using Ombi.Core.Services;
+using Ombi.Core.Settings;
+using Ombi.Settings.Settings.Models;
+using Ombi.Store.Entities;
+using Ombi.Store.Entities.Requests;
+using Ombi.Store.Repository.Requests;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Ombi.Core.Tests.Services
+{
+ [TestFixture]
+ public class RecentlyRequestedServiceTests
+ {
+ private AutoMocker _mocker;
+ private RecentlyRequestedService _subject;
+ private Fixture _fixture;
+
+ [SetUp]
+ public void Setup()
+ {
+ _fixture = new Fixture();
+
+ _fixture.Behaviors.OfType().ToList()
+ .ForEach(b => _fixture.Behaviors.Remove(b));
+ _fixture.Behaviors.Add(new OmitOnRecursionBehavior());
+ _mocker = new AutoMocker();
+
+ _mocker.Setup>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Alias = "alias", Language = "en" });
+ _mocker.Setup(x => x.Username).Returns("test");
+ _subject = _mocker.CreateInstance();
+ }
+
+ [Test]
+ public async Task GetRecentlyRequested_Movies()
+ {
+ _mocker.Setup, Task>(x => x.GetSettingsAsync())
+ .ReturnsAsync(new CustomizationSettings());
+ var releaseDate = new DateTime(2019, 01, 01);
+ var requestDate = DateTime.Now;
+ var movies = new List
+ {
+ new MovieRequests
+ {
+ Id = 1,
+ Approved = true,
+ Available = true,
+ ReleaseDate = releaseDate,
+ Title = "title",
+ Overview = "overview",
+ RequestedDate = requestDate,
+ RequestedUser = new Store.Entities.OmbiUser
+ {
+ UserName = "a"
+ },
+ RequestedUserId = "b",
+ }
+ };
+ var albums = new List();
+ var chilRequests = new List();
+ _mocker.Setup>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetRecentlyRequested(CancellationToken.None);
+
+ Assert.That(result.Count, Is.EqualTo(1));
+ Assert.That(result.First(), Is.InstanceOf()
+ .With.Property(nameof(RecentlyRequestedModel.RequestId)).EqualTo(1)
+ .With.Property(nameof(RecentlyRequestedModel.Approved)).EqualTo(true)
+ .With.Property(nameof(RecentlyRequestedModel.Available)).EqualTo(true)
+ .With.Property(nameof(RecentlyRequestedModel.Title)).EqualTo("title")
+ .With.Property(nameof(RecentlyRequestedModel.Overview)).EqualTo("overview")
+ .With.Property(nameof(RecentlyRequestedModel.RequestDate)).EqualTo(requestDate)
+ .With.Property(nameof(RecentlyRequestedModel.ReleaseDate)).EqualTo(releaseDate)
+ .With.Property(nameof(RecentlyRequestedModel.Type)).EqualTo(RequestType.Movie)
+ );
+ }
+
+ [Test]
+ public async Task GetRecentlyRequested_Movies_HideAvailable()
+ {
+ _mocker.Setup, Task>(x => x.GetSettingsAsync())
+ .ReturnsAsync(new CustomizationSettings() { HideAvailableRecentlyRequested = true });
+ var releaseDate = new DateTime(2019, 01, 01);
+ var requestDate = DateTime.Now;
+ var movies = new List
+ {
+ new MovieRequests
+ {
+ Id = 1,
+ Approved = true,
+ Available = true,
+ ReleaseDate = releaseDate,
+ Title = "title",
+ Overview = "overview",
+ RequestedDate = requestDate,
+ RequestedUser = new Store.Entities.OmbiUser
+ {
+ UserName = "a"
+ },
+ RequestedUserId = "b",
+ },
+
+ new MovieRequests
+ {
+ Id = 1,
+ Approved = true,
+ Available = false,
+ ReleaseDate = releaseDate,
+ Title = "title2",
+ Overview = "overview2",
+ RequestedDate = requestDate,
+ RequestedUser = new Store.Entities.OmbiUser
+ {
+ UserName = "a"
+ },
+ RequestedUserId = "b",
+ }
+ };
+ var albums = new List();
+ var chilRequests = new List();
+ _mocker.Setup>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetRecentlyRequested(CancellationToken.None);
+
+ Assert.That(result.Count, Is.EqualTo(1));
+ Assert.That(result.First(), Is.InstanceOf()
+ .With.Property(nameof(RecentlyRequestedModel.RequestId)).EqualTo(1)
+ .With.Property(nameof(RecentlyRequestedModel.Approved)).EqualTo(true)
+ .With.Property(nameof(RecentlyRequestedModel.Available)).EqualTo(false)
+ .With.Property(nameof(RecentlyRequestedModel.Title)).EqualTo("title2")
+ .With.Property(nameof(RecentlyRequestedModel.Overview)).EqualTo("overview2")
+ .With.Property(nameof(RecentlyRequestedModel.RequestDate)).EqualTo(requestDate)
+ .With.Property(nameof(RecentlyRequestedModel.ReleaseDate)).EqualTo(releaseDate)
+ .With.Property(nameof(RecentlyRequestedModel.Type)).EqualTo(RequestType.Movie)
+ );
+ }
+
+ [Test]
+ public async Task GetRecentlyRequested()
+ {
+ _mocker.Setup, Task>(x => x.GetSettingsAsync())
+ .ReturnsAsync(new CustomizationSettings());
+ var releaseDate = new DateTime(2019, 01, 01);
+ var requestDate = DateTime.Now;
+
+ var movies = _fixture.CreateMany(10);
+ var albums = _fixture.CreateMany(10);
+ var chilRequests = _fixture.CreateMany(10);
+
+ _mocker.Setup>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock().Object);
+
+ var result = await _subject.GetRecentlyRequested(CancellationToken.None);
+
+ Assert.That(result.Count, Is.EqualTo(21));
+ }
+
+
+ [Test]
+ public async Task GetRecentlyRequested_HideUsernames()
+ {
+ _mocker.Setup, Task>(x => x.GetSettingsAsync())
+ .ReturnsAsync(new CustomizationSettings());
+ _mocker.Setup, Task>(x => x.GetSettingsAsync())
+ .ReturnsAsync(new OmbiSettings { HideRequestsUsers = true });
+ var releaseDate = new DateTime(2019, 01, 01);
+ var requestDate = DateTime.Now;
+
+ var movies = _fixture.CreateMany(10);
+ var albums = _fixture.CreateMany(10);
+ var chilRequests = _fixture.CreateMany(10);
+
+ _mocker.Setup>(x => x.GetAll()).Returns(movies.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetAll()).Returns(albums.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetChild()).Returns(chilRequests.AsQueryable().BuildMock().Object);
+ _mocker.Setup>(x => x.GetUser()).ReturnsAsync(new OmbiUser { UserName = "test", Alias = "alias", UserType = UserType.LocalUser });
+ _mocker.Setup(x => x.Username).Returns("test");
+ _mocker.Setup>(x => x.IsInRoleAsync(It.IsAny(), It.IsAny())).ReturnsAsync(false);
+
+ var result = await _subject.GetRecentlyRequested(CancellationToken.None);
+
+ CollectionAssert.IsEmpty(result.Where(x => !string.IsNullOrEmpty(x.Username) && !string.IsNullOrEmpty(x.UserId)));
+ }
+ }
+}
diff --git a/src/Ombi.Core/Engine/MovieRequestEngine.cs b/src/Ombi.Core/Engine/MovieRequestEngine.cs
index e5114677b..109460ff9 100644
--- a/src/Ombi.Core/Engine/MovieRequestEngine.cs
+++ b/src/Ombi.Core/Engine/MovieRequestEngine.cs
@@ -111,11 +111,11 @@ namespace Ombi.Core.Engine
if (model.Is4kRequest)
{
existingRequest.Is4kRequest = true;
- existingRequest.RequestedDate4k = DateTime.Now;
+ existingRequest.RequestedDate4k = DateTime.UtcNow;
}
else
{
- existingRequest.RequestedDate = DateTime.Now;
+ existingRequest.RequestedDate = DateTime.UtcNow;
}
isExisting = true;
requestModel = existingRequest;
@@ -134,7 +134,7 @@ namespace Ombi.Core.Engine
? DateTime.Parse(movieInfo.ReleaseDate)
: DateTime.MinValue,
Status = movieInfo.Status,
- RequestedDate = model.Is4kRequest ? DateTime.MinValue : DateTime.Now,
+ RequestedDate = model.Is4kRequest ? DateTime.MinValue : DateTime.UtcNow,
Approved = false,
Approved4K = false,
RequestedUserId = canRequestOnBehalf ? model.RequestOnBehalf : userDetails.Id,
@@ -143,7 +143,7 @@ namespace Ombi.Core.Engine
RequestedByAlias = model.RequestedByAlias,
RootPathOverride = model.RootFolderOverride.GetValueOrDefault(),
QualityOverride = model.QualityPathOverride.GetValueOrDefault(),
- RequestedDate4k = model.Is4kRequest ? DateTime.Now : DateTime.MinValue,
+ RequestedDate4k = model.Is4kRequest ? DateTime.UtcNow : DateTime.MinValue,
Is4kRequest = model.Is4kRequest,
Source = model.Source
};
diff --git a/src/Ombi.Core/Engine/UserDeletionEngine.cs b/src/Ombi.Core/Engine/UserDeletionEngine.cs
index 7df394592..1c8fd63ca 100644
--- a/src/Ombi.Core/Engine/UserDeletionEngine.cs
+++ b/src/Ombi.Core/Engine/UserDeletionEngine.cs
@@ -26,6 +26,7 @@ namespace Ombi.Core.Engine
private readonly IMusicRequestRepository _musicRepository;
private readonly IRepository _voteRepository;
private readonly IRepository _mobileDevicesRepository;
+ private readonly IRepository _watchlistUserError;
public UserDeletionEngine(IMovieRequestRepository movieRepository,
OmbiUserManager userManager,
@@ -39,7 +40,8 @@ namespace Ombi.Core.Engine
IRepository notificationPreferencesRepo,
IRepository qualityProfilesRepo,
IRepository voteRepository,
- IRepository mobileDevicesRepository
+ IRepository mobileDevicesRepository,
+ IRepository watchlistUserError
)
{
_movieRepository = movieRepository;
@@ -56,6 +58,7 @@ namespace Ombi.Core.Engine
_userQualityProfiles = qualityProfilesRepo;
_voteRepository = voteRepository;
_mobileDevicesRepository = mobileDevicesRepository;
+ _watchlistUserError = watchlistUserError;
}
@@ -68,6 +71,7 @@ namespace Ombi.Core.Engine
var musicRequested = _musicRepository.GetAll().Where(x => x.RequestedUserId == userId);
var notificationPreferences = _userNotificationPreferences.GetAll().Where(x => x.UserId == userId);
var userQuality = await _userQualityProfiles.GetAll().FirstOrDefaultAsync(x => x.UserId == userId);
+ var watchlistError = await _watchlistUserError.GetAll().FirstOrDefaultAsync(x => x.UserId == userId);
if (moviesUserRequested.Any())
{
@@ -89,6 +93,10 @@ namespace Ombi.Core.Engine
{
await _userQualityProfiles.Delete(userQuality);
}
+ if (watchlistError != null)
+ {
+ await _watchlistUserError.Delete(watchlistError);
+ }
// Delete any issues and request logs
var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId);
diff --git a/src/Ombi.Core/Engine/UserStatsEngine.cs b/src/Ombi.Core/Engine/UserStatsEngine.cs
index 6b26591f4..f079aa156 100644
--- a/src/Ombi.Core/Engine/UserStatsEngine.cs
+++ b/src/Ombi.Core/Engine/UserStatsEngine.cs
@@ -25,28 +25,29 @@ namespace Ombi.Core.Engine
{
// get all movie requests
var movies = _movieRequest.GetWithUser();
- var filteredMovies = movies.Where(x => x.RequestedDate >= request.From && x.RequestedDate <= request.To);
+ var filteredMovies = await movies.Where(x => x.RequestedDate >= request.From && x.RequestedDate <= request.To).ToListAsync();
var tv = _tvRequest.GetLite();
- var children = tv.SelectMany(x =>
- x.ChildRequests.Where(c => c.RequestedDate >= request.From && c.RequestedDate <= request.To));
+ var children = await tv.SelectMany(x =>
+ x.ChildRequests.Where(c => c.RequestedDate >= request.From && c.RequestedDate <= request.To)).ToListAsync();
+
+ var userMovie = filteredMovies.GroupBy(x => x.RequestedUserId).OrderBy(x => x.Key).FirstOrDefault();
+ var userTv = children.GroupBy(x => x.RequestedUserId).OrderBy(x => x.Key).FirstOrDefault();
- var userMovie = filteredMovies.GroupBy(x => x.RequestedUserId).OrderBy(x => x.Key).FirstOrDefaultAsync();
- var userTv = children.GroupBy(x => x.RequestedUserId).OrderBy(x => x.Key).FirstOrDefaultAsync();
- var moviesCount = filteredMovies.CountAsync();
- var childrenCount = children.CountAsync();
+ var moviesCount = filteredMovies.Count;
+ var childrenCount = children.Count;
var availableMovies =
- filteredMovies.Select(x => x.MarkedAsAvailable >= request.From && x.MarkedAsAvailable <= request.To).CountAsync();
- var availableChildren = children.Where(c => c.MarkedAsAvailable >= request.From && c.MarkedAsAvailable <= request.To).CountAsync();
+ filteredMovies.Select(x => x.MarkedAsAvailable >= request.From && x.MarkedAsAvailable <= request.To).Count();
+ var availableChildren = children.Where(c => c.MarkedAsAvailable >= request.From && c.MarkedAsAvailable <= request.To).Count();
return new UserStatsSummary
{
- TotalMovieRequests = await moviesCount,
- TotalTvRequests = await childrenCount,
- CompletedRequestsTv = await availableChildren,
- CompletedRequestsMovies = await availableMovies,
- MostRequestedUserMovie = (await userMovie).FirstOrDefault()?.RequestedUser ?? new OmbiUser(),
- MostRequestedUserTv = (await userTv).FirstOrDefault()?.RequestedUser ?? new OmbiUser(),
+ TotalMovieRequests = moviesCount,
+ TotalTvRequests = childrenCount,
+ CompletedRequestsTv = availableChildren,
+ CompletedRequestsMovies = availableMovies,
+ MostRequestedUserMovie = userMovie.FirstOrDefault()?.RequestedUser ?? new OmbiUser(),
+ MostRequestedUserTv = userTv.FirstOrDefault()?.RequestedUser ?? new OmbiUser(),
};
}
}
diff --git a/src/Ombi.Core/IImageService.cs b/src/Ombi.Core/IImageService.cs
index 1493133e6..7a3bf0d4e 100644
--- a/src/Ombi.Core/IImageService.cs
+++ b/src/Ombi.Core/IImageService.cs
@@ -1,9 +1,12 @@
-using System.Threading.Tasks;
+using System.Threading;
+using System.Threading.Tasks;
namespace Ombi.Core
{
public interface IImageService
{
Task GetTvBackground(string tvdbId);
+ Task GetTmdbTvBackground(string id, CancellationToken token);
+ Task GetTmdbTvPoster(string tmdbId, CancellationToken token);
}
}
\ No newline at end of file
diff --git a/src/Ombi.Core/ImageService.cs b/src/Ombi.Core/ImageService.cs
index f9c8b40b9..9df9ef6e1 100644
--- a/src/Ombi.Core/ImageService.cs
+++ b/src/Ombi.Core/ImageService.cs
@@ -1,8 +1,13 @@
using System;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using Ombi.Api.FanartTv;
+using Ombi.Api.TheMovieDb;
+using Ombi.Core.Helpers;
+using Ombi.Core.Settings;
using Ombi.Helpers;
+using Ombi.Settings.Settings.Models;
using Ombi.Store.Repository;
namespace Ombi.Core
@@ -12,13 +17,19 @@ namespace Ombi.Core
private readonly IApplicationConfigRepository _configRepository;
private readonly IFanartTvApi _fanartTvApi;
private readonly ICacheService _cache;
+ private readonly IMovieDbApi _movieDbApi;
+ private readonly ICurrentUser _user;
+ private readonly ISettingsService _ombiSettings;
public ImageService(IApplicationConfigRepository configRepository, IFanartTvApi fanartTvApi,
- ICacheService cache)
+ ICacheService cache, IMovieDbApi movieDbApi, ICurrentUser user, ISettingsService ombiSettings)
{
_configRepository = configRepository;
_fanartTvApi = fanartTvApi;
_cache = cache;
+ _movieDbApi = movieDbApi;
+ _user = user;
+ _ombiSettings = ombiSettings;
}
public async Task GetTvBackground(string tvdbId)
@@ -43,5 +54,69 @@ namespace Ombi.Core
return string.Empty;
}
+
+ public async Task GetTmdbTvBackground(string id, CancellationToken token)
+ {
+ var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}tv{id}", () => _movieDbApi.GetTvImages(id, token), DateTimeOffset.Now.AddDays(1));
+
+ if (images?.backdrops?.Any() ?? false)
+ {
+ return images.backdrops.Select(x => x.file_path).FirstOrDefault();
+ }
+ if (images?.posters?.Any() ?? false)
+ {
+ return images.posters.Select(x => x.file_path).FirstOrDefault();
+ }
+
+ return string.Empty;
+ }
+
+ public async Task GetTmdbTvPoster(string tmdbId, CancellationToken token)
+ {
+ var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}tv{tmdbId}", () => _movieDbApi.GetTvImages(tmdbId, token), DateTimeOffset.Now.AddDays(1));
+
+ if (images?.posters?.Any() ?? false)
+ {
+ var lang = await DefaultLanguageCode();
+ var langImage = images.posters.Where(x => lang.Equals(x.iso_639_1, StringComparison.InvariantCultureIgnoreCase)).OrderByDescending(x => x.vote_count);
+ if (langImage.Any())
+ {
+ return langImage.Select(x => x.file_path).First();
+ }
+ else
+ {
+ return images.posters.Select(x => x.file_path).First();
+ }
+ }
+
+ if (images?.backdrops?.Any() ?? false)
+ {
+ return images.backdrops.Select(x => x.file_path).FirstOrDefault();
+ }
+ return string.Empty;
+ }
+
+ protected async Task DefaultLanguageCode()
+ {
+ var user = await _user.GetUser();
+ if (user == null)
+ {
+ return "en";
+ }
+
+ if (string.IsNullOrEmpty(user.Language))
+ {
+ var s = await GetOmbiSettings();
+ return s.DefaultLanguageCode;
+ }
+
+ return user.Language;
+ }
+
+ private OmbiSettings ombiSettings;
+ protected async Task GetOmbiSettings()
+ {
+ return ombiSettings ?? (ombiSettings = await _ombiSettings.GetSettingsAsync());
+ }
}
}
\ No newline at end of file
diff --git a/src/Ombi.Core/Models/PlexUserWatchlistModel.cs b/src/Ombi.Core/Models/PlexUserWatchlistModel.cs
new file mode 100644
index 000000000..83652b105
--- /dev/null
+++ b/src/Ombi.Core/Models/PlexUserWatchlistModel.cs
@@ -0,0 +1,16 @@
+namespace Ombi.Core.Models
+{
+ public class PlexUserWatchlistModel
+ {
+ public string UserId { get; set; }
+ public WatchlistSyncStatus SyncStatus { get; set; }
+ public string UserName { get; set; }
+ }
+
+ public enum WatchlistSyncStatus
+ {
+ Successful,
+ Failed,
+ NotEnabled
+ }
+}
diff --git a/src/Ombi.Core/Models/Requests/RecentlyRequestedModel.cs b/src/Ombi.Core/Models/Requests/RecentlyRequestedModel.cs
new file mode 100644
index 000000000..4296c2cc1
--- /dev/null
+++ b/src/Ombi.Core/Models/Requests/RecentlyRequestedModel.cs
@@ -0,0 +1,24 @@
+using Ombi.Store.Entities;
+using System;
+
+namespace Ombi.Core.Models.Requests
+{
+ public class RecentlyRequestedModel
+ {
+ public int RequestId { get; set; }
+ public RequestType Type { get; set; }
+ public string UserId { get; set; }
+ public string Username { get; set; }
+ public bool Available { get; set; }
+ public bool TvPartiallyAvailable { get; set; }
+ public DateTime RequestDate { get; set; }
+ public string Title { get; set; }
+ public string Overview { get; set; }
+ public DateTime ReleaseDate { get; set; }
+ public bool Approved { get; set; }
+ public string MediaId { get; set; }
+
+ public string PosterPath { get; set; }
+ public string Background { get; set; }
+ }
+}
diff --git a/src/Ombi.Core/Senders/TvSender.cs b/src/Ombi.Core/Senders/TvSender.cs
index 22f6aadcd..1daa1bf0f 100644
--- a/src/Ombi.Core/Senders/TvSender.cs
+++ b/src/Ombi.Core/Senders/TvSender.cs
@@ -157,7 +157,6 @@ namespace Ombi.Core.Senders
}
int qualityToUse;
- var sonarrV3 = s.V3;
var languageProfileId = s.LanguageProfile;
string rootFolderPath;
string seriesType;
@@ -265,13 +264,11 @@ namespace Ombi.Core.Senders
ignoreEpisodesWithFiles = false, // There shouldn't be any episodes with files, this is a new season
ignoreEpisodesWithoutFiles = false, // We want all missing
searchForMissingEpisodes = false // we want dont want to search yet. We want to make sure everything is unmonitored/monitored correctly.
- }
- };
+ },
+ languageProfileId = languageProfileId
+ };
- if (sonarrV3)
- {
- newSeries.languageProfileId = languageProfileId;
- }
+
// Montitor the correct seasons,
// If we have that season in the model then it's monitored!
diff --git a/src/Ombi.Core/Services/IPlexService.cs b/src/Ombi.Core/Services/IPlexService.cs
new file mode 100644
index 000000000..4cacdc4e5
--- /dev/null
+++ b/src/Ombi.Core/Services/IPlexService.cs
@@ -0,0 +1,12 @@
+using Ombi.Core.Models;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Ombi.Core.Services
+{
+ public interface IPlexService
+ {
+ Task
> GetWatchlistUsers(CancellationToken cancellationToken);
+ }
+}
diff --git a/src/Ombi.Core/Services/IRecentlyRequestedService.cs b/src/Ombi.Core/Services/IRecentlyRequestedService.cs
new file mode 100644
index 000000000..21604c14d
--- /dev/null
+++ b/src/Ombi.Core/Services/IRecentlyRequestedService.cs
@@ -0,0 +1,12 @@
+using Ombi.Core.Models.Requests;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Ombi.Core.Services
+{
+ public interface IRecentlyRequestedService
+ {
+ Task> GetRecentlyRequested(CancellationToken cancellationToken);
+ }
+}
diff --git a/src/Ombi.Core/Services/PlexService.cs b/src/Ombi.Core/Services/PlexService.cs
new file mode 100644
index 000000000..4d3f41bda
--- /dev/null
+++ b/src/Ombi.Core/Services/PlexService.cs
@@ -0,0 +1,55 @@
+using Microsoft.EntityFrameworkCore;
+using Ombi.Core.Authentication;
+using Ombi.Core.Models;
+using Ombi.Store.Entities;
+using Ombi.Store.Repository;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using UserType = Ombi.Store.Entities.UserType;
+
+namespace Ombi.Core.Services
+{
+ public class PlexService : IPlexService
+ {
+ private readonly IRepository _watchlistUserErrors;
+ private readonly OmbiUserManager _userManager;
+
+ public PlexService(IRepository watchlistUserErrors, OmbiUserManager userManager)
+ {
+ _watchlistUserErrors = watchlistUserErrors;
+ _userManager = userManager;
+ }
+
+ public async Task> GetWatchlistUsers(CancellationToken cancellationToken)
+ {
+ var plexUsers = _userManager.Users.Where(x => x.UserType == UserType.PlexUser);
+ var userErrors = await _watchlistUserErrors.GetAll().ToListAsync(cancellationToken);
+
+ var model = new List();
+
+
+ foreach(var plexUser in plexUsers)
+ {
+ model.Add(new PlexUserWatchlistModel
+ {
+ UserId = plexUser.Id,
+ UserName = plexUser.UserName,
+ SyncStatus = GetWatchlistSyncStatus(plexUser, userErrors)
+ });
+ }
+
+ return model;
+ }
+
+ private static WatchlistSyncStatus GetWatchlistSyncStatus(OmbiUser user, List userErrors)
+ {
+ if (string.IsNullOrWhiteSpace(user.MediaServerToken))
+ {
+ return WatchlistSyncStatus.NotEnabled;
+ }
+ return userErrors.Any(x => x.UserId == user.Id) ? WatchlistSyncStatus.Failed : WatchlistSyncStatus.Successful;
+ }
+ }
+}
diff --git a/src/Ombi.Core/Services/RecentlyRequestedService.cs b/src/Ombi.Core/Services/RecentlyRequestedService.cs
new file mode 100644
index 000000000..1c67472d4
--- /dev/null
+++ b/src/Ombi.Core/Services/RecentlyRequestedService.cs
@@ -0,0 +1,183 @@
+using Microsoft.EntityFrameworkCore;
+using Ombi.Api.TheMovieDb;
+using Ombi.Core.Authentication;
+using Ombi.Core.Engine.Interfaces;
+using Ombi.Core.Helpers;
+using Ombi.Core.Models.Requests;
+using Ombi.Core.Rule.Interfaces;
+using Ombi.Core.Settings;
+using Ombi.Helpers;
+using Ombi.Settings.Settings.Models;
+using Ombi.Store.Entities;
+using Ombi.Store.Repository.Requests;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using static Ombi.Core.Engine.BaseMediaEngine;
+
+namespace Ombi.Core.Services
+{
+ public class RecentlyRequestedService : BaseEngine, IRecentlyRequestedService
+ {
+ private readonly IMovieRequestRepository _movieRequestRepository;
+ private readonly ITvRequestRepository _tvRequestRepository;
+ private readonly IMusicRequestRepository _musicRequestRepository;
+ private readonly ISettingsService _customizationSettings;
+ private readonly ISettingsService _ombiSettings;
+ private readonly IMovieDbApi _movieDbApi;
+ private readonly ICacheService _cache;
+ private const int AmountToTake = 7;
+
+ public RecentlyRequestedService(
+ IMovieRequestRepository movieRequestRepository,
+ ITvRequestRepository tvRequestRepository,
+ IMusicRequestRepository musicRequestRepository,
+ ISettingsService customizationSettings,
+ ISettingsService ombiSettings,
+ ICurrentUser user,
+ OmbiUserManager um,
+ IRuleEvaluator rules,
+ IMovieDbApi movieDbApi,
+ ICacheService cache) : base(user, um, rules)
+ {
+ _movieRequestRepository = movieRequestRepository;
+ _tvRequestRepository = tvRequestRepository;
+ _musicRequestRepository = musicRequestRepository;
+ _customizationSettings = customizationSettings;
+ _ombiSettings = ombiSettings;
+ _movieDbApi = movieDbApi;
+ _cache = cache;
+ }
+
+ public async Task> GetRecentlyRequested(CancellationToken cancellationToken)
+ {
+ var customizationSettingsTask = _customizationSettings.GetSettingsAsync();
+
+ var recentMovieRequests = _movieRequestRepository.GetAll().Include(x => x.RequestedUser).OrderByDescending(x => x.RequestedDate).Take(AmountToTake);
+ var recentTvRequests = _tvRequestRepository.GetChild().Include(x => x.RequestedUser).Include(x => x.ParentRequest).OrderByDescending(x => x.RequestedDate).Take(AmountToTake);
+ var recentMusicRequests = _musicRequestRepository.GetAll().Include(x => x.RequestedUser).OrderByDescending(x => x.RequestedDate).Take(AmountToTake);
+
+ var settings = await customizationSettingsTask;
+ if (settings.HideAvailableRecentlyRequested)
+ {
+ recentMovieRequests = recentMovieRequests.Where(x => !x.Available);
+ recentTvRequests = recentTvRequests.Where(x => !x.Available);
+ recentMusicRequests = recentMusicRequests.Where(x => !x.Available);
+ }
+ var hideUsers = await HideFromOtherUsers();
+
+ var model = new List();
+
+ var lang = await DefaultLanguageCode();
+ foreach (var item in await recentMovieRequests.ToListAsync(cancellationToken))
+ {
+ var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}movie{item.TheMovieDbId}", () => _movieDbApi.GetMovieImages(item.TheMovieDbId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1));
+ model.Add(new RecentlyRequestedModel
+ {
+ RequestId = item.Id,
+ Available = item.Available,
+ Overview = item.Overview,
+ ReleaseDate = item.ReleaseDate,
+ RequestDate = item.RequestedDate,
+ Title = item.Title,
+ Type = RequestType.Movie,
+ Approved = item.Approved,
+ UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
+ Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
+ MediaId = item.TheMovieDbId.ToString(),
+ PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
+ Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
+ });
+ }
+
+ foreach (var item in await recentMusicRequests.ToListAsync(cancellationToken))
+ {
+ model.Add(new RecentlyRequestedModel
+ {
+ RequestId = item.Id,
+ Available = item.Available,
+ Overview = item.ArtistName,
+ Approved = item.Approved,
+ ReleaseDate = item.ReleaseDate,
+ RequestDate = item.RequestedDate,
+ Title = item.Title,
+ Type = RequestType.Album,
+ UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
+ Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
+ MediaId = item.ForeignAlbumId,
+ });
+ }
+
+ foreach (var item in await recentTvRequests.ToListAsync(cancellationToken))
+ {
+ var providerId = item.ParentRequest.ExternalProviderId.ToString();
+ var images = await _cache.GetOrAddAsync($"{CacheKeys.TmdbImages}tv{providerId}", () => _movieDbApi.GetTvImages(providerId.ToString(), cancellationToken), DateTimeOffset.Now.AddDays(1));
+
+ var partialAvailability = item.SeasonRequests.SelectMany(x => x.Episodes).Any(e => e.Available);
+ model.Add(new RecentlyRequestedModel
+ {
+ RequestId = item.Id,
+ Available = item.Available,
+ Overview = item.ParentRequest.Overview,
+ ReleaseDate = item.ParentRequest.ReleaseDate,
+ Approved = item.Approved,
+ RequestDate = item.RequestedDate,
+ TvPartiallyAvailable = partialAvailability,
+ Title = item.ParentRequest.Title,
+ Type = RequestType.TvShow,
+ UserId = hideUsers.Hide ? string.Empty : item.RequestedUserId,
+ Username = hideUsers.Hide ? string.Empty : item.RequestedUser.UserAlias,
+ MediaId = providerId.ToString(),
+ PosterPath = images?.posters?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
+ Background = images?.backdrops?.Where(x => lang.Equals(x?.iso_639_1, StringComparison.InvariantCultureIgnoreCase))?.OrderByDescending(x => x.vote_count)?.Select(x => x.file_path)?.FirstOrDefault(),
+ });
+ }
+
+ return model.OrderByDescending(x => x.RequestDate);
+ }
+
+ private async Task HideFromOtherUsers()
+ {
+ var user = await GetUser();
+ if (await IsInRole(OmbiRoles.Admin) || await IsInRole(OmbiRoles.PowerUser) || user.IsSystemUser)
+ {
+ return new HideResult
+ {
+ UserId = user.Id
+ };
+ }
+ var settings = await GetOmbiSettings();
+ var result = new HideResult
+ {
+ Hide = settings.HideRequestsUsers,
+ UserId = user.Id
+ };
+ return result;
+ }
+ protected async Task DefaultLanguageCode()
+ {
+ var user = await GetUser();
+ if (user == null)
+ {
+ return "en";
+ }
+
+ if (string.IsNullOrEmpty(user.Language))
+ {
+ var s = await GetOmbiSettings();
+ return s.DefaultLanguageCode;
+ }
+
+ return user.Language;
+ }
+
+
+ private OmbiSettings ombiSettings;
+ protected async Task GetOmbiSettings()
+ {
+ return ombiSettings ??= await _ombiSettings.GetSettingsAsync();
+ }
+ }
+}
diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs
index 691aca237..9e47042de 100644
--- a/src/Ombi.DependencyInjection/IocExtensions.cs
+++ b/src/Ombi.DependencyInjection/IocExtensions.cs
@@ -228,6 +228,8 @@ namespace Ombi.DependencyInjection
services.AddTransient();
services.AddTransient();
services.AddScoped();
+ services.AddTransient();
+ services.AddTransient();
}
public static void RegisterJobs(this IServiceCollection services)
diff --git a/src/Ombi.Helpers/CacheKeys.cs b/src/Ombi.Helpers/CacheKeys.cs
index 89faead8a..06e406d64 100644
--- a/src/Ombi.Helpers/CacheKeys.cs
+++ b/src/Ombi.Helpers/CacheKeys.cs
@@ -21,6 +21,7 @@ namespace Ombi.Helpers
public const string LidarrRootFolders = nameof(LidarrRootFolders);
public const string LidarrQualityProfiles = nameof(LidarrQualityProfiles);
public const string FanartTv = nameof(FanartTv);
+ public const string TmdbImages = nameof(TmdbImages);
public const string UsersDropdown = nameof(UsersDropdown);
}
}
diff --git a/src/Ombi.Helpers/MediaCacheService.cs b/src/Ombi.Helpers/MediaCacheService.cs
index 8d244f4b3..27e9bb6d5 100644
--- a/src/Ombi.Helpers/MediaCacheService.cs
+++ b/src/Ombi.Helpers/MediaCacheService.cs
@@ -13,7 +13,7 @@ namespace Ombi.Helpers
}
public class MediaCacheService : CacheService, IMediaCacheService
{
- private const string CacheKey = "MediaCacheServiceKeys";
+ private const string _cacheKey = "MediaCacheServiceKeys";
public MediaCacheService(IMemoryCache memoryCache) : base(memoryCache)
{
@@ -43,19 +43,19 @@ namespace Ombi.Helpers
private void UpdateLocalCache(string cacheKey)
{
- var mediaServiceCache = _memoryCache.Get>(CacheKey);
+ var mediaServiceCache = _memoryCache.Get>(_cacheKey);
if (mediaServiceCache == null)
{
mediaServiceCache = new List();
}
mediaServiceCache.Add(cacheKey);
- _memoryCache.Remove(CacheKey);
- _memoryCache.Set(CacheKey, mediaServiceCache);
+ _memoryCache.Remove(_cacheKey);
+ _memoryCache.Set(_cacheKey, mediaServiceCache);
}
public Task Purge()
{
- var keys = _memoryCache.Get>(CacheKey);
+ var keys = _memoryCache.Get>(_cacheKey);
if (keys == null)
{
return Task.CompletedTask;
diff --git a/src/Ombi.Hubs/NotificationHub.cs b/src/Ombi.Hubs/NotificationHub.cs
index 54d13884a..5e211b093 100644
--- a/src/Ombi.Hubs/NotificationHub.cs
+++ b/src/Ombi.Hubs/NotificationHub.cs
@@ -24,7 +24,11 @@ namespace Ombi.Hubs
{
get
{
- return UsersOnline.Where(x => x.Value.Roles.Contains(OmbiRoles.Admin)).Select(x => x.Key).ToList();
+ if (UsersOnline.Any())
+ {
+ return UsersOnline.Where(x => x.Value.Roles.Contains(OmbiRoles.Admin)).Select(x => x.Key).ToList();
+ }
+ return Enumerable.Empty().ToList();
}
}
diff --git a/src/Ombi.I18n/Resources/Texts.sk.resx b/src/Ombi.I18n/Resources/Texts.sk.resx
index 8fb4b7157..e5c0b8cc9 100644
--- a/src/Ombi.I18n/Resources/Texts.sk.resx
+++ b/src/Ombi.I18n/Resources/Texts.sk.resx
@@ -118,13 +118,13 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- New Albums
+ Nový album
- New Movies
+ Nové filmy
- New TV
+ Nové seriály
Žánre:
@@ -139,18 +139,18 @@
Epizódy:
- Powered by
+ Beží na
- Unsubscribe
+ Zrušiť odber
Album
- Movie
+ Film
- TV Show
+ Seriál
\ No newline at end of file
diff --git a/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs b/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs
index 783844a82..2ea500872 100644
--- a/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs
+++ b/src/Ombi.Notifications.Tests/NotificationMessageCurlysTests.cs
@@ -292,6 +292,8 @@ namespace Ombi.Notifications.Tests
notificationOptions.Substitutes.Add("Season", "1");
notificationOptions.Substitutes.Add("Episodes", "1, 2");
+ notificationOptions.Substitutes.Add("EpisodesCount", "2");
+ notificationOptions.Substitutes.Add("SeasonEpisodes", "1x1, 1x2");
var req = F.Build()
.With(x => x.RequestType, RequestType.TvShow)
.With(x => x.Available, true)
@@ -324,6 +326,8 @@ namespace Ombi.Notifications.Tests
Assert.That("name", Is.EqualTo(sut.ApplicationName));
Assert.That(sut.PartiallyAvailableEpisodeNumbers, Is.EqualTo("1, 2"));
Assert.That(sut.PartiallyAvailableSeasonNumber, Is.EqualTo("1"));
+ Assert.That(sut.PartiallyAvailableEpisodeCount, Is.EqualTo("2"));
+ Assert.That(sut.PartiallyAvailableEpisodesList, Is.EqualTo("1x1, 1x2"));
}
[Test]
diff --git a/src/Ombi.Notifications/NotificationMessageCurlys.cs b/src/Ombi.Notifications/NotificationMessageCurlys.cs
index 7696c9c16..f079c03a3 100644
--- a/src/Ombi.Notifications/NotificationMessageCurlys.cs
+++ b/src/Ombi.Notifications/NotificationMessageCurlys.cs
@@ -186,6 +186,14 @@ namespace Ombi.Notifications
{
PartiallyAvailableEpisodeNumbers = epNumber;
}
+ if (opts.Substitutes.TryGetValue("EpisodesCount", out var epCount))
+ {
+ PartiallyAvailableEpisodeCount = epCount;
+ }
+ if (opts.Substitutes.TryGetValue("SeasonEpisodes", out var sEpisodes))
+ {
+ PartiallyAvailableEpisodesList = sEpisodes;
+ }
}
}
@@ -295,6 +303,8 @@ namespace Ombi.Notifications
public string ProviderId { get; set; }
public string PartiallyAvailableEpisodeNumbers { get; set; }
public string PartiallyAvailableSeasonNumber { get; set; }
+ public string PartiallyAvailableEpisodeCount { get; set; }
+ public string PartiallyAvailableEpisodesList { get; set; }
// System Defined
private string LongDate => DateTime.Now.ToString("D");
@@ -336,6 +346,8 @@ namespace Ombi.Notifications
{ nameof(ProviderId), ProviderId },
{ nameof(PartiallyAvailableEpisodeNumbers), PartiallyAvailableEpisodeNumbers },
{ nameof(PartiallyAvailableSeasonNumber), PartiallyAvailableSeasonNumber },
+ { nameof(PartiallyAvailableEpisodesList), PartiallyAvailableEpisodesList },
+ { nameof(PartiallyAvailableEpisodeCount), PartiallyAvailableEpisodeCount },
};
}
}
\ No newline at end of file
diff --git a/src/Ombi.Schedule.Tests/AvailabilityCheckerTests.cs b/src/Ombi.Schedule.Tests/AvailabilityCheckerTests.cs
new file mode 100644
index 000000000..d909b7519
--- /dev/null
+++ b/src/Ombi.Schedule.Tests/AvailabilityCheckerTests.cs
@@ -0,0 +1,192 @@
+using Microsoft.AspNetCore.SignalR;
+using Microsoft.Extensions.Logging;
+using MockQueryable.Moq;
+using Moq;
+using Moq.AutoMock;
+using NUnit.Framework;
+using Ombi.Core;
+using Ombi.Hubs;
+using Ombi.Notifications.Models;
+using Ombi.Schedule.Jobs;
+using Ombi.Store.Entities;
+using Ombi.Store.Entities.Requests;
+using Ombi.Store.Repository.Requests;
+using Ombi.Tests;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Ombi.Schedule.Tests
+{
+ [TestFixture]
+ public class AvailabilityCheckerTests
+ {
+ private AutoMocker _mocker;
+ private TestAvailabilityChecker _subject;
+
+ [SetUp]
+ public void SetUp()
+ {
+ _mocker = new AutoMocker();
+ var hub = SignalRHelper.MockHub();
+ _mocker.Use(hub);
+
+ _subject = _mocker.CreateInstance();
+ }
+
+ [Test]
+ public async Task All_Episodes_Are_Available_In_Request()
+ {
+ var request = new ChildRequests
+ {
+ Title = "Test",
+ Id = 1,
+ RequestedUser = new OmbiUser { Email = "" },
+ SeasonRequests = new List
+ {
+ new SeasonRequests
+ {
+ Episodes = new List
+ {
+ new EpisodeRequests
+ {
+ Available = false,
+ EpisodeNumber = 1,
+ Season = new SeasonRequests
+ {
+ SeasonNumber = 1
+ }
+ },
+ new EpisodeRequests
+ {
+ Available = false,
+ EpisodeNumber = 2,
+ Season = new SeasonRequests
+ {
+ SeasonNumber = 1
+ }
+ }
+ }
+ }
+ }
+ };
+
+ var databaseEpisodes = new List
+ {
+ new PlexEpisode
+ {
+ EpisodeNumber = 1,
+ SeasonNumber = 1,
+ },
+ new PlexEpisode
+ {
+ EpisodeNumber = 2,
+ SeasonNumber = 1,
+ },
+ }.AsQueryable().BuildMock().Object;
+
+ await _subject.ProcessTvShow(databaseEpisodes, request);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(request.Available, Is.True);
+ Assert.That(request.MarkedAsAvailable, Is.Not.Null);
+ Assert.That(request.SeasonRequests[0].Episodes[0].Available, Is.True);
+ Assert.That(request.SeasonRequests[0].Episodes[1].Available, Is.True);
+ });
+
+ Assert.Multiple(() =>
+ {
+ _mocker.Verify(x => x.Save(), Times.Exactly(2));
+ _mocker.Verify(x => x.Notify(It.Is(x => x.NotificationType == Helpers.NotificationType.RequestAvailable && x.RequestId == 1)), Times.Once);
+ });
+ }
+
+ [Test]
+ public async Task All_One_Episode_Is_Available_In_Request()
+ {
+ var request = new ChildRequests
+ {
+ Title = "Test",
+ Id = 1,
+ RequestedUser = new OmbiUser { Email = "" },
+ SeasonRequests = new List
+ {
+ new SeasonRequests
+ {
+ Episodes = new List
+ {
+ new EpisodeRequests
+ {
+ Available = false,
+ EpisodeNumber = 1,
+ Season = new SeasonRequests
+ {
+ SeasonNumber = 1
+ }
+ },
+ new EpisodeRequests
+ {
+ Available = false,
+ EpisodeNumber = 2,
+ Season = new SeasonRequests
+ {
+ SeasonNumber = 1
+ }
+ },
+ new EpisodeRequests
+ {
+ Available = true,
+ EpisodeNumber = 3,
+ Season = new SeasonRequests
+ {
+ SeasonNumber = 1
+ }
+ }
+ }
+ }
+ }
+ };
+
+ var databaseEpisodes = new List
+ {
+ new PlexEpisode
+ {
+ EpisodeNumber = 1,
+ SeasonNumber = 1,
+ },
+ new PlexEpisode
+ {
+ EpisodeNumber = 3,
+ SeasonNumber = 1,
+ },
+ }.AsQueryable().BuildMock().Object;
+
+ await _subject.ProcessTvShow(databaseEpisodes, request);
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(request.Available, Is.False);
+ Assert.That(request.MarkedAsAvailable, Is.Null);
+ Assert.That(request.SeasonRequests[0].Episodes[0].Available, Is.True);
+ Assert.That(request.SeasonRequests[0].Episodes[1].Available, Is.False);
+ });
+
+ Assert.Multiple(() =>
+ {
+ _mocker.Verify(x => x.Save(), Times.Once);
+ _mocker.Verify(x => x.Notify(It.Is(x => x.NotificationType == Helpers.NotificationType.PartiallyAvailable && x.RequestId == 1)), Times.Once);
+ });
+ }
+ }
+
+
+ public class TestAvailabilityChecker : AvailabilityChecker
+ {
+ public TestAvailabilityChecker(ITvRequestRepository tvRequest, INotificationHelper notification, ILogger log, IHubContext hub) : base(tvRequest, notification, log, hub)
+ {
+ }
+
+ public new Task ProcessTvShow(IQueryable seriesEpisodes, ChildRequests child) => base.ProcessTvShow(seriesEpisodes, child);
+ }
+}
diff --git a/src/Ombi.Schedule.Tests/Ombi.Schedule.Tests.csproj b/src/Ombi.Schedule.Tests/Ombi.Schedule.Tests.csproj
index d8e698d0e..d2215c5f1 100644
--- a/src/Ombi.Schedule.Tests/Ombi.Schedule.Tests.csproj
+++ b/src/Ombi.Schedule.Tests/Ombi.Schedule.Tests.csproj
@@ -20,6 +20,7 @@
+
diff --git a/src/Ombi.Schedule.Tests/PlexAvailabilityCheckerTests.cs b/src/Ombi.Schedule.Tests/PlexAvailabilityCheckerTests.cs
index 6a549458b..d25bb8413 100644
--- a/src/Ombi.Schedule.Tests/PlexAvailabilityCheckerTests.cs
+++ b/src/Ombi.Schedule.Tests/PlexAvailabilityCheckerTests.cs
@@ -19,49 +19,140 @@ using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests;
using Ombi.Helpers;
using Ombi.Core.Services;
+using Ombi.Tests;
+using Moq.AutoMock;
+using Ombi.Settings.Settings.Models;
+using Ombi.Notifications.Models;
namespace Ombi.Schedule.Tests
{
[TestFixture]
- [Ignore("Need to work out how to mockout the hub context")]
public class PlexAvailabilityCheckerTests
{
+ private AutoMocker _mocker;
+ private PlexAvailabilityChecker _subject;
+
[SetUp]
public void Setup()
{
- _repo = new Mock();
- _tv = new Mock();
- _movie = new Mock();
- _notify = new Mock();
- var hub = new Mock>();
- hub.Setup(x =>
- x.Clients.Clients(It.IsAny>()).SendCoreAsync(It.IsAny(), It.IsAny |