Skip to content

Commit

Permalink
Merge pull request #2597 from tidusjar/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tidusjar authored Oct 17, 2018
2 parents a898bf4 + f380859 commit fed5ad4
Show file tree
Hide file tree
Showing 169 changed files with 5,842 additions and 618 deletions.
131 changes: 131 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,138 @@
# Changelog

## (unreleased)

### **New Features**

- Added automation tests for the voting feature. [TidusJar]

- Update LidarrAvailabilityChecker.cs. [Jamie]

- Update CHANGELOG.md. [Jamie]

- Changes language selector to always show native language name. [Victor Usoltsev]

- Updated test dependancies. [TidusJar]

- Added in the external repo so we can rip out external stuff. [TidusJar]

- Added the ability to purge/remove issues. [TidusJar]

### **Fixes**

- New translations en.json (French) [Jamie]

- New translations en.json (French) [Jamie]

- New translations en.json (French) [Jamie]

- New translations en.json (French) [Jamie]

- New translations en.json (Swedish) [Jamie]

- New translations en.json (Spanish) [Jamie]

- New translations en.json (Portuguese, Brazilian) [Jamie]

- New translations en.json (Polish) [Jamie]

- New translations en.json (Norwegian) [Jamie]

- New translations en.json (Italian) [Jamie]

- New translations en.json (German) [Jamie]

- New translations en.json (French) [Jamie]

- New translations en.json (Dutch) [Jamie]

- New translations en.json (Danish) [Jamie]

- When a users requests content and the voting is enabled, the user who requested is an automatic +1 vote. [TidusJar]

- Revert, no idea how this happened. [TidusJar]

- Fixed the build. Thanks Matt! [TidusJar]

- Fixes untickable mass email checkboxes in Safari. [Victor Usoltsev]

- [ImgBot] optimizes images. [ImgBotApp]

- Revert "Feature/purge issues" [Jamie]

- Fixed the issue where user preferences was not being inported into some notifications. [TidusJar]

- New role to enable users to remove their own requests. [Anojh]

- Users can now remove their own requests. [Anojh]

- New translations en.json (Danish) [Jamie]

- Fixed lidarr newsletter bug. [Jamie]

- Potentially fix the user profiles issue. [Jamie]

- Hides Radarr options on movie requests page if only 1 option available. [Victor Usoltsev]

- Hides Sonarr options on tv requests page if only 1 option available. [Victor Usoltsev]

- Fixed the issue where we could not delete users #2558. [TidusJar]

- New translations en.json (German) [Jamie]

- New translations en.json (Swedish) [Jamie]

- New translations en.json (Spanish) [Jamie]

- New translations en.json (Portuguese, Brazilian) [Jamie]

- New translations en.json (Polish) [Jamie]

- New translations en.json (Norwegian) [Jamie]

- New translations en.json (Italian) [Jamie]

- New translations en.json (German) [Jamie]

- New translations en.json (French) [Jamie]

- New translations en.json (Dutch) [Jamie]

- New translations en.json (Danish) [Jamie]

- Subscribe the user to the request when they vote on it. [TidusJar]

- Fixed #2555. [Jamie]

- Fixed #2549. [Jamie]

- Removed the pinID from the OAuth url #2548. [Jamie]

- Put the issue purge limit on the issues page. [Jamie]

- Date and times are now in the local users date time. [TidusJar]

- Fixed the migration. [TidusJar]

- ExternalContext migrations. [TidusJar]

- The settings have now been split out of the main db. [TidusJar]

- Search for the Lidarr Album when it's a new artist. [TidusJar]

- The album in Lidarr does not need to be marked as monitored for us to pick up it's available. Fixes #2536. [Jamie]

- Truncate the request title. [Jamie]

- Fixed #2535. [Jamie]


## v3.0.3795 (2018-09-23)

### **New Features**

- Update CHANGELOG.md. [Jamie]

### **Fixes**

- Fixed the issue with notifications not sending. [Jamie]
Expand Down
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ configuration: Release
os: Visual Studio 2017
environment:
nodejs_version: "9.8.0"
typescript_version: "3.0.1"

install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version

- cmd: set path=%programfiles(x86)%\\Microsoft SDKs\TypeScript\3.0;%path%
- cmd: tsc -v
build_script:
- ps: ./build.ps1 --settings_skipverification=true

Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Api.Notifications/OneSignalApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<OneSignalNotificationResponse> PushNotification(List<string> p
{
return null;
}
var id = await _appConfig.Get(ConfigurationTypes.Notification);
var id = await _appConfig.GetAsync(ConfigurationTypes.Notification);
var request = new Request(string.Empty, ApiUrl, HttpMethod.Post);

var body = new OneSignalNotificationBody
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Api.Plex/IPlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface IPlexApi
Task<PlexAccount> GetAccount(string authToken);
Task<PlexMetadata> GetRecentlyAdded(string authToken, string uri, string sectionId);
Task<OAuthPin> GetPin(int pinId);
Task<Uri> GetOAuthUrl(int pinId, string code, string applicationUrl);
Task<Uri> GetOAuthUrl(string code, string applicationUrl);
Task<PlexAddWrapper> AddUser(string emailAddress, string serverId, string authToken, int[] libs);
}
}
3 changes: 1 addition & 2 deletions src/Ombi.Api.Plex/PlexApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,11 @@ public async Task<OAuthPin> GetPin(int pinId)
return await Api.Request<OAuthPin>(request);
}

public async Task<Uri> GetOAuthUrl(int pinId, string code, string applicationUrl)
public async Task<Uri> GetOAuthUrl(string code, string applicationUrl)
{
var request = new Request("auth#", "https://app.plex.tv", HttpMethod.Get);
await AddHeaders(request);

request.AddQueryString("pinID", pinId.ToString());
request.AddQueryString("code", code);
request.AddQueryString("context[device][product]", ApplicationName);
request.AddQueryString("context[device][environment]", "bundled");
Expand Down
73 changes: 73 additions & 0 deletions src/Ombi.Core.Tests/Engine/VoteEngineTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using AutoFixture;
using Moq;
using NUnit.Framework;
using Ombi.Core.Authentication;
using Ombi.Core.Engine;
using Ombi.Core.Engine.Interfaces;
using Ombi.Core.Rule.Interfaces;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;

namespace Ombi.Core.Tests.Engine
{
[TestFixture]
public class VoteEngineTests
{
[SetUp]
public void Setup()
{
F = new Fixture();
VoteRepository = new Mock<IRepository<Votes>>();
VoteSettings = new Mock<ISettingsService<VoteSettings>>();
MusicRequestEngine = new Mock<IMusicRequestEngine>();
TvRequestEngine = new Mock<ITvRequestEngine>();
MovieRequestEngine = new Mock<IMovieRequestEngine>();
MovieRequestEngine = new Mock<IMovieRequestEngine>();
User = new Mock<IPrincipal>();
UserManager = new Mock<OmbiUserManager>();
UserManager.Setup(x => x.Users)
.Returns(new EnumerableQuery<OmbiUser>(new List<OmbiUser> {new OmbiUser {Id = "abc"}}));
Rule = new Mock<IRuleEvaluator>();
Engine = new VoteEngine(VoteRepository.Object, User.Object, UserManager.Object, Rule.Object, VoteSettings.Object, MusicRequestEngine.Object,
TvRequestEngine.Object, MovieRequestEngine.Object);
}

public Fixture F { get; set; }
public VoteEngine Engine { get; set; }
public Mock<IPrincipal> User { get; set; }
public Mock<OmbiUserManager> UserManager { get; set; }
public Mock<IRuleEvaluator> Rule { get; set; }
public Mock<IRepository<Votes>> VoteRepository { get; set; }
public Mock<ISettingsService<VoteSettings>> VoteSettings { get; set; }
public Mock<IMusicRequestEngine> MusicRequestEngine { get; set; }
public Mock<ITvRequestEngine> TvRequestEngine { get; set; }
public Mock<IMovieRequestEngine> MovieRequestEngine { get; set; }

[Test]
[Ignore("Need to mock the user manager")]
public async Task New_Upvote()
{
VoteSettings.Setup(x => x.GetSettingsAsync()).ReturnsAsync(new VoteSettings());
var votes = F.CreateMany<Votes>().ToList();
votes.Add(new Votes
{
RequestId = 1,
RequestType = RequestType.Movie,
UserId = "abc"
});
VoteRepository.Setup(x => x.GetAll()).Returns(new EnumerableQuery<Votes>(votes));
var result = await Engine.UpVote(1, RequestType.Movie);

Assert.That(result.Result, Is.True);
VoteRepository.Verify(x => x.Add(It.Is<Votes>(c => c.UserId == "abc" && c.VoteType == VoteType.Upvote)), Times.Once);
VoteRepository.Verify(x => x.Delete(It.IsAny<Votes>()), Times.Once);
MovieRequestEngine.Verify(x => x.ApproveMovieById(1), Times.Never);
}
}
}
5 changes: 3 additions & 2 deletions src/Ombi.Core.Tests/Ombi.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.9.0" />
<PackageReference Include="AutoFixture" Version="4.5.0" />
<PackageReference Include="Moq" Version="4.10.0" />
<PackageReference Include="Nunit" Version="3.10.1" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.8.0" />
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<packagereference Include="Microsoft.NET.Test.Sdk" Version="15.8.0"></packagereference>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Ombi.Core/Authentication/PlexOAuthManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ public async Task<PlexAccount> GetAccount(string accessToken)
return await _api.GetAccount(accessToken);
}

public async Task<Uri> GetOAuthUrl(int pinId, string code, string websiteAddress = null)
public async Task<Uri> GetOAuthUrl(string code, string websiteAddress = null)
{
var settings = await _customizationSettingsService.GetSettingsAsync();
var url = await _api.GetOAuthUrl(pinId, code, settings.ApplicationUrl.IsNullOrEmpty() ? websiteAddress : settings.ApplicationUrl);
var url = await _api.GetOAuthUrl(code, settings.ApplicationUrl.IsNullOrEmpty() ? websiteAddress : settings.ApplicationUrl);

return url;
}

public async Task<Uri> GetWizardOAuthUrl(int pinId, string code, string websiteAddress)
public async Task<Uri> GetWizardOAuthUrl(string code, string websiteAddress)
{
var url = await _api.GetOAuthUrl(pinId, code, websiteAddress);
var url = await _api.GetOAuthUrl(code, websiteAddress);
return url;
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/Ombi.Core/Engine/IVoteEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Ombi.Core.Models;
using Ombi.Core.Models.UI;
using Ombi.Store.Entities;

namespace Ombi.Core.Engine
{
public interface IVoteEngine
{
Task<VoteEngineResult> DownVote(int requestId, RequestType requestType);
Task<Votes> GetVoteForUser(int requestId, string userId);
IQueryable<Votes> GetVotes(int requestId, RequestType requestType);
Task RemoveCurrentVote(Votes currentVote);
Task<VoteEngineResult> UpVote(int requestId, RequestType requestType);
Task<List<VoteViewModel>> GetMovieViewModel();
}
}
3 changes: 0 additions & 3 deletions src/Ombi.Core/Engine/Interfaces/BaseEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
using Ombi.Core.Rule.Interfaces;
using Ombi.Store.Entities.Requests;
using Ombi.Store.Entities;
using Microsoft.AspNetCore.Identity;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Ombi.Core.Authentication;
using Ombi.Helpers;

namespace Ombi.Core.Engine.Interfaces
{
Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Core/Engine/Interfaces/IMovieRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IMovieRequestEngine : IRequestEngine<MovieRequests>
Task<IEnumerable<MovieRequests>> SearchMovieRequest(string search);

Task RemoveMovieRequest(int requestId);
Task RemoveAllMovieRequests();

Task<MovieRequests> UpdateMovieRequest(MovieRequests request);
Task<RequestEngineResult> ApproveMovie(MovieRequests request);
Expand Down
8 changes: 7 additions & 1 deletion src/Ombi.Core/Engine/MovieRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ public async Task RemoveMovieRequest(int requestId)
await MovieRepository.Delete(request);
}

public async Task RemoveAllMovieRequests()
{
var request = MovieRepository.GetAll();
await MovieRepository.DeleteRange(request);
}

public async Task<bool> UserHasRequest(string userId)
{
return await MovieRepository.GetAll().AnyAsync(x => x.RequestedUserId == userId);
Expand Down Expand Up @@ -483,7 +489,7 @@ await _requestLog.Add(new RequestLog
RequestType = RequestType.Movie,
});

return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!"};
return new RequestEngineResult {Result = true, Message = $"{movieName} has been successfully added!", RequestId = model.Id};
}

public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
Expand Down
2 changes: 1 addition & 1 deletion src/Ombi.Core/Engine/MusicRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ await _requestLog.Add(new RequestLog
RequestType = RequestType.Album,
});

return new RequestEngineResult { Result = true, Message = $"{model.Title} has been successfully added!" };
return new RequestEngineResult { Result = true, Message = $"{model.Title} has been successfully added!", RequestId = model.Id };
}


Expand Down
1 change: 1 addition & 0 deletions src/Ombi.Core/Engine/RequestEngineResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class RequestEngineResult
public string Message { get; set; }
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
public string ErrorMessage { get; set; }
public int RequestId { get; set; }
}
}
7 changes: 4 additions & 3 deletions src/Ombi.Core/Engine/TvRequestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,16 @@ await _requestLog.Add(new RequestLog
var result = await TvSender.Send(model);
if (result.Success)
{
return new RequestEngineResult { Result = true };
return new RequestEngineResult { Result = true, RequestId = model.Id};
}
return new RequestEngineResult
{
ErrorMessage = result.Message
ErrorMessage = result.Message,
RequestId = model.Id
};
}

return new RequestEngineResult { Result = true };
return new RequestEngineResult { Result = true, RequestId = model.Id };
}

public async Task<RequestQuotaCountModel> GetRemainingRequests(OmbiUser user)
Expand Down
Loading

0 comments on commit fed5ad4

Please sign in to comment.