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:
@ -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)
|
||||
{
|
||||
|
30
src/Api/Models/Response/CipherHistoryResponseModel.cs
Normal file
30
src/Api/Models/Response/CipherHistoryResponseModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user