diff --git a/src/Core/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommand.cs b/src/Core/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommand.cs index ee6d70a95..a54223f68 100644 --- a/src/Core/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommand.cs +++ b/src/Core/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommand.cs @@ -8,6 +8,7 @@ using Bit.Core.Exceptions; using Bit.Core.KeyManagement.Commands.Interfaces; using Bit.Core.KeyManagement.Models.Data; using Bit.Core.KeyManagement.Repositories; +using Bit.Core.Services; using Microsoft.Extensions.Logging; namespace Bit.Core.KeyManagement.Commands; @@ -17,15 +18,18 @@ public class RegenerateUserAsymmetricKeysCommand : IRegenerateUserAsymmetricKeys private readonly ICurrentContext _currentContext; private readonly ILogger _logger; private readonly IUserAsymmetricKeysRepository _userAsymmetricKeysRepository; + private readonly IPushNotificationService _pushService; public RegenerateUserAsymmetricKeysCommand( ICurrentContext currentContext, IUserAsymmetricKeysRepository userAsymmetricKeysRepository, + IPushNotificationService pushService, ILogger logger) { _currentContext = currentContext; _logger = logger; _userAsymmetricKeysRepository = userAsymmetricKeysRepository; + _pushService = pushService; } public async Task RegenerateKeysAsync(UserAsymmetricKeys userAsymmetricKeys, @@ -61,5 +65,7 @@ public class RegenerateUserAsymmetricKeysCommand : IRegenerateUserAsymmetricKeys _logger.LogInformation( "User's asymmetric keys regenerated. UserId: {userId} OrganizationMembership: {inOrganizations} DesignatedEmergencyAccess: {hasDesignatedEmergencyAccess} DeviceType: {deviceType}", userAsymmetricKeys.UserId, inOrganizations, hasDesignatedEmergencyAccess, _currentContext.DeviceType); + + await _pushService.PushSyncSettingsAsync(userId.Value); } } diff --git a/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs b/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs index ce2b9afef..338895615 100644 --- a/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs +++ b/test/Core.Test/KeyManagement/Commands/RegenerateUserAsymmetricKeysCommandTests.cs @@ -8,6 +8,7 @@ using Bit.Core.Exceptions; using Bit.Core.KeyManagement.Commands; using Bit.Core.KeyManagement.Models.Data; using Bit.Core.KeyManagement.Repositories; +using Bit.Core.Services; using Bit.Test.Common.AutoFixture; using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; @@ -49,6 +50,9 @@ public class RegenerateUserAsymmetricKeysCommandTests await sutProvider.GetDependency() .Received(1) .RegenerateUserAsymmetricKeysAsync(Arg.Is(userAsymmetricKeys)); + await sutProvider.GetDependency() + .Received(1) + .PushSyncSettingsAsync(Arg.Is(userAsymmetricKeys.UserId)); } [Theory] @@ -88,6 +92,9 @@ public class RegenerateUserAsymmetricKeysCommandTests await sutProvider.GetDependency() .ReceivedWithAnyArgs(0) .RegenerateUserAsymmetricKeysAsync(Arg.Any()); + await sutProvider.GetDependency() + .ReceivedWithAnyArgs(0) + .PushSyncSettingsAsync(Arg.Any()); } [Theory] @@ -110,6 +117,9 @@ public class RegenerateUserAsymmetricKeysCommandTests await sutProvider.GetDependency() .ReceivedWithAnyArgs(0) .RegenerateUserAsymmetricKeysAsync(Arg.Any()); + await sutProvider.GetDependency() + .ReceivedWithAnyArgs(0) + .PushSyncSettingsAsync(Arg.Any()); } [Theory] @@ -134,6 +144,9 @@ public class RegenerateUserAsymmetricKeysCommandTests await sutProvider.GetDependency() .ReceivedWithAnyArgs(0) .RegenerateUserAsymmetricKeysAsync(Arg.Any()); + await sutProvider.GetDependency() + .ReceivedWithAnyArgs(0) + .PushSyncSettingsAsync(Arg.Any()); } private static ICollection CreateInOrganizationAccounts(Guid userId,