1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-22 12:15:36 +01:00

add sends to sync response (#1002)

This commit is contained in:
Kyle Spearrin 2020-11-18 13:55:50 -05:00 committed by GitHub
parent faf909479e
commit 58eb0510ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -26,6 +26,7 @@ namespace Bit.Api.Controllers
private readonly ICollectionCipherRepository _collectionCipherRepository;
private readonly IOrganizationUserRepository _organizationUserRepository;
private readonly IPolicyRepository _policyRepository;
private readonly ISendRepository _sendRepository;
private readonly GlobalSettings _globalSettings;
public SyncController(
@ -36,6 +37,7 @@ namespace Bit.Api.Controllers
ICollectionCipherRepository collectionCipherRepository,
IOrganizationUserRepository organizationUserRepository,
IPolicyRepository policyRepository,
ISendRepository sendRepository,
GlobalSettings globalSettings)
{
_userService = userService;
@ -45,11 +47,12 @@ namespace Bit.Api.Controllers
_collectionCipherRepository = collectionCipherRepository;
_organizationUserRepository = organizationUserRepository;
_policyRepository = policyRepository;
_sendRepository = sendRepository;
_globalSettings = globalSettings;
}
[HttpGet("")]
public async Task<SyncResponseModel> Get([FromQuery]bool excludeDomains = false)
public async Task<SyncResponseModel> Get([FromQuery] bool excludeDomains = false)
{
var user = await _userService.GetUserByPrincipalAsync(User);
if (user == null)
@ -62,6 +65,7 @@ namespace Bit.Api.Controllers
var hasEnabledOrgs = organizationUserDetails.Any(o => o.Enabled);
var folders = await _folderRepository.GetManyByUserIdAsync(user.Id);
var ciphers = await _cipherRepository.GetManyByUserIdAsync(user.Id, hasEnabledOrgs);
var sends = await _sendRepository.GetManyByUserIdAsync(user.Id);
IEnumerable<CollectionDetails> collections = null;
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersGroupDict = null;
@ -76,7 +80,7 @@ namespace Bit.Api.Controllers
var userTwoFactorEnabled = await _userService.TwoFactorIsEnabledAsync(user);
var response = new SyncResponseModel(_globalSettings, user, userTwoFactorEnabled, organizationUserDetails,
folders, collections, ciphers, collectionCiphersGroupDict, excludeDomains, policies);
folders, collections, ciphers, collectionCiphersGroupDict, excludeDomains, policies, sends);
return response;
}
}

View File

@ -19,7 +19,8 @@ namespace Bit.Core.Models.Api
IEnumerable<CipherDetails> ciphers,
IDictionary<Guid, IGrouping<Guid, CollectionCipher>> collectionCiphersDict,
bool excludeDomains,
IEnumerable<Policy> policies)
IEnumerable<Policy> policies,
IEnumerable<Send> sends)
: base("sync")
{
Profile = new ProfileResponseModel(user, organizationUserDetails, userTwoFactorEnabled);
@ -29,6 +30,7 @@ namespace Bit.Core.Models.Api
c => new CollectionDetailsResponseModel(c)) ?? new List<CollectionDetailsResponseModel>();
Domains = excludeDomains ? null : new DomainsResponseModel(user, false);
Policies = policies?.Select(p => new PolicyResponseModel(p)) ?? new List<PolicyResponseModel>();
Sends = sends.Select(s => new SendResponseModel(s, globalSettings));
}
public ProfileResponseModel Profile { get; set; }
@ -37,5 +39,6 @@ namespace Bit.Core.Models.Api
public IEnumerable<CipherDetailsResponseModel> Ciphers { get; set; }
public DomainsResponseModel Domains { get; set; }
public IEnumerable<PolicyResponseModel> Policies { get; set; }
public IEnumerable<SendResponseModel> Sends { get; set; }
}
}