mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Fixed the issue where we cannot delete a user #4050
This commit is contained in:
parent
f94f4ac1c0
commit
728741bfa1
1 changed files with 14 additions and 4 deletions
|
@ -5,6 +5,7 @@ using Ombi.Store.Entities;
|
|||
using Ombi.Store.Entities.Requests;
|
||||
using Ombi.Store.Repository;
|
||||
using Ombi.Store.Repository.Requests;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
@ -93,18 +94,27 @@ namespace Ombi.Core.Engine
|
|||
var issues = _issuesRepository.GetAll().Where(x => x.UserReportedId == userId);
|
||||
var issueComments = _issueCommentsRepository.GetAll().Where(x => x.UserId == userId);
|
||||
var requestLog = _requestLogRepository.GetAll().Where(x => x.UserId == userId);
|
||||
|
||||
if (issueComments.Any())
|
||||
{
|
||||
await _issueCommentsRepository.DeleteRange(issueComments);
|
||||
}
|
||||
if (issues.Any())
|
||||
{
|
||||
var extraComments = new List<IssueComments>();
|
||||
var issueIds = issues.Select(x => x.Id).Distinct();
|
||||
foreach (var issue in issueIds)
|
||||
{
|
||||
// Get all the comments for this issue and delete them, since the issue will be deleted
|
||||
var extra = _issueCommentsRepository.GetAll().Where(x => x.IssuesId == issue);
|
||||
extraComments.AddRange(extra.ToList());
|
||||
}
|
||||
await _issuesRepository.DeleteRange(issues);
|
||||
}
|
||||
if (requestLog.Any())
|
||||
{
|
||||
await _requestLogRepository.DeleteRange(requestLog);
|
||||
}
|
||||
if (issueComments.Any())
|
||||
{
|
||||
await _issueCommentsRepository.DeleteRange(issueComments);
|
||||
}
|
||||
|
||||
// Delete the Subscriptions and mobile notification ids
|
||||
var subs = _requestSubscriptionRepository.GetAll().Where(x => x.UserId == userId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue