1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

added cipher history API for data syncing with client databases

This commit is contained in:
Kyle Spearrin
2016-06-08 20:40:20 -04:00
parent 6861303586
commit 89e524e1e4
6 changed files with 86 additions and 0 deletions

View File

@ -50,6 +50,14 @@ namespace Bit.Api.Controllers
return new ListResponseModel<CipherResponseModel>(responses);
}
[HttpGet("history")]
public async Task<CipherHistoryResponseModel> Get(DateTime since)
{
var history = await _cipherRepository.GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(
since, new Guid(_userManager.GetUserId(User)));
return new CipherHistoryResponseModel(history.Item1, history.Item2);
}
[HttpPost("import")]
public async Task PostImport([FromBody]ImportRequestModel model)
{

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Bit.Core.Domains;
namespace Bit.Api.Models
{
public class CipherHistoryResponseModel : ResponseModel
{
public CipherHistoryResponseModel(IEnumerable<Cipher> revisedCiphers, IEnumerable<Guid> deletedIds)
: base("cipherHistory")
{
if(revisedCiphers == null)
{
throw new ArgumentNullException(nameof(revisedCiphers));
}
if(deletedIds == null)
{
throw new ArgumentNullException(nameof(deletedIds));
}
Revised = revisedCiphers.Select(c => new CipherResponseModel(c));
Deleted = deletedIds.Select(id => id.ToString());
}
public IEnumerable<CipherResponseModel> Revised { get; set; }
public IEnumerable<string> Deleted { get; set; }
}
}