|
|
|
@ -218,6 +218,45 @@ namespace Ombi.Core.Engine
|
|
|
|
|
return allRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<TvRequests>> GetRequestsLite()
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
List<TvRequests> allRequests;
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite(shouldHide.UserId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
FilterChildren(allRequests, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
allRequests = await TvRepository.GetLite().ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allRequests.ForEach(async r => { await CheckForSubscription(shouldHide, r); });
|
|
|
|
|
return allRequests;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<TvRequests> GetTvRequest(int requestId)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
|
TvRequests request;
|
|
|
|
|
if (shouldHide.Hide)
|
|
|
|
|
{
|
|
|
|
|
request = await TvRepository.Get(shouldHide.UserId).Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
FilterChildren(request, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
request = await TvRepository.Get().Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await CheckForSubscription(shouldHide, request);
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FilterChildren(IEnumerable<TvRequests> allRequests, HideResult shouldHide)
|
|
|
|
|
{
|
|
|
|
|
// Filter out children
|
|
|
|
@ -225,16 +264,27 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
for (var j = 0; j < t.ChildRequests.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
var child = t.ChildRequests[j];
|
|
|
|
|
if (child.RequestedUserId != shouldHide.UserId)
|
|
|
|
|
{
|
|
|
|
|
t.ChildRequests.RemoveAt(j);
|
|
|
|
|
j--;
|
|
|
|
|
}
|
|
|
|
|
FilterChildren(t, shouldHide);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void FilterChildren(TvRequests t, HideResult shouldHide)
|
|
|
|
|
{
|
|
|
|
|
// Filter out children
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < t.ChildRequests.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
var child = t.ChildRequests[j];
|
|
|
|
|
if (child.RequestedUserId != shouldHide.UserId)
|
|
|
|
|
{
|
|
|
|
|
t.ChildRequests.RemoveAt(j);
|
|
|
|
|
j--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<ChildRequests>> GetAllChldren(int tvId)
|
|
|
|
|
{
|
|
|
|
|
var shouldHide = await HideFromOtherUsers();
|
|
|
|
@ -470,7 +520,7 @@ namespace Ombi.Core.Engine
|
|
|
|
|
{
|
|
|
|
|
foreach (var tv in x.ChildRequests)
|
|
|
|
|
{
|
|
|
|
|
await CheckForSubscription(shouldHide, tv);
|
|
|
|
|
await CheckForSubscription(shouldHide, tv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|