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

This commit is contained in:
TidusJar 2018-10-10 21:39:59 +01:00
commit 4508f79a5f
7 changed files with 68 additions and 14 deletions

View file

@ -149,13 +149,17 @@ namespace Ombi.Core.Engine
public async Task<VoteEngineResult> UpVote(int requestId, RequestType requestType)
{
var voteSettings = await _voteSettings.GetSettingsAsync();
if (!voteSettings.Enabled)
{
return new VoteEngineResult {Result = true};
}
// How many votes does this have?!
var currentVotes = GetVotes(requestId, requestType);
var voteSettings = await _voteSettings.GetSettingsAsync();
// Does this user have a downvote? If so we should revert it and make it an upvote
var user = await GetUser();
// Does this user have a downvote? If so we should revert it and make it an upvote
var currentVote = await GetVoteForUser(requestId, user.Id);
if (currentVote != null && currentVote.VoteType == VoteType.Upvote)
{
@ -206,7 +210,7 @@ namespace Ombi.Core.Engine
{
return new VoteEngineResult
{
ErrorMessage = "Voted succesfully but could not approve movie!"
ErrorMessage = "Voted succesfully but could not approve!"
};
}
@ -218,6 +222,11 @@ namespace Ombi.Core.Engine
public async Task<VoteEngineResult> DownVote(int requestId, RequestType requestType)
{
var voteSettings = await _voteSettings.GetSettingsAsync();
if (!voteSettings.Enabled)
{
return new VoteEngineResult { Result = true };
}
var user = await GetUser();
var currentVote = await GetVoteForUser(requestId, user.Id);
if (currentVote != null && currentVote.VoteType == VoteType.Downvote)