diff --git a/src/Core/Services/IUserService.cs b/src/Core/Services/IUserService.cs index 0094538eb..d8bcfaf89 100644 --- a/src/Core/Services/IUserService.cs +++ b/src/Core/Services/IUserService.cs @@ -45,7 +45,9 @@ public interface IUserService Task GenerateUserTokenAsync(User user, string tokenProvider, string purpose); Task DeleteAsync(User user); Task DeleteAsync(User user, string token); +#nullable enable Task> DeleteManyAsync(IEnumerable users); +#nullable disable Task SendDeleteConfirmationAsync(string email); Task> SignUpPremiumAsync(User user, string paymentToken, PaymentMethodType paymentMethodType, short additionalStorageGb, UserLicense license, diff --git a/src/Core/Services/Implementations/UserService.cs b/src/Core/Services/Implementations/UserService.cs index 3e3476906..935ec92a6 100644 --- a/src/Core/Services/Implementations/UserService.cs +++ b/src/Core/Services/Implementations/UserService.cs @@ -243,11 +243,14 @@ public class UserService : UserManager, IUserService, IDisposable } } +#nullable enable public async Task> DeleteManyAsync(IEnumerable users) { var results = await ValidateDeleteUsersAsync(users.ToList()); - await _userRepository.DeleteManyAsync(users); + var usersToDelete = users.Where(user => results.Select(r => r.UserId == user.Id && string.IsNullOrEmpty(r.ErrorMessage)).Count() > 1); + + await _userRepository.DeleteManyAsync(usersToDelete); foreach (var user in users) { await _referenceEventService.RaiseEventAsync( @@ -257,6 +260,7 @@ public class UserService : UserManager, IUserService, IDisposable return results; } +#nullable disable public async Task DeleteAsync(User user, string token) { @@ -268,6 +272,7 @@ public class UserService : UserManager, IUserService, IDisposable return await DeleteAsync(user); } +#nullable enable private async Task> ValidateDeleteUsersAsync(List users) { var userResult = new List<(Guid UserId, string? ErrorMessage)>(); @@ -322,6 +327,7 @@ public class UserService : UserManager, IUserService, IDisposable } return userResult; } +#nullable disable public async Task SendDeleteConfirmationAsync(string email) {