1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-15 15:53:44 +00:00

Beginning of policy support (#736)

* Model & service support for policies

* Formatting

* Changes to match existing service and model patterns
This commit is contained in:
Matt Portune
2020-02-21 10:23:38 -05:00
committed by GitHub
parent ec3660a86d
commit 387dc2f59c
9 changed files with 172 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ namespace Bit.Core.Services
private readonly ICollectionService _collectionService;
private readonly IStorageService _storageService;
private readonly IMessagingService _messagingService;
private readonly IPolicyService _policyService;
private readonly Func<bool, Task> _logoutCallbackAsync;
public SyncService(
@@ -35,6 +36,7 @@ namespace Bit.Core.Services
ICollectionService collectionService,
IStorageService storageService,
IMessagingService messagingService,
IPolicyService policyService,
Func<bool, Task> logoutCallbackAsync)
{
_userService = userService;
@@ -46,6 +48,7 @@ namespace Bit.Core.Services
_collectionService = collectionService;
_storageService = storageService;
_messagingService = messagingService;
_policyService = policyService;
_logoutCallbackAsync = logoutCallbackAsync;
}
@@ -101,6 +104,7 @@ namespace Bit.Core.Services
await SyncCollectionsAsync(response.Collections);
await SyncCiphersAsync(userId, response.Ciphers);
await SyncSettingsAsync(userId, response.Domains);
await SyncPolicies(response.Policies);
await SetLastSyncAsync(now);
return SyncCompleted(true);
}
@@ -358,5 +362,11 @@ namespace Bit.Core.Services
}
await _settingsService.SetEquivalentDomainsAsync(eqDomains);
}
private async Task SyncPolicies(List<PolicyResponse> response)
{
var policies = response.ToDictionary(p => p.Id, p => new PolicyData(p));
await _policyService.Replace(policies);
}
}
}