mirror of
https://github.com/bitwarden/server.git
synced 2025-07-07 02:52:50 -05:00
Getting rid of CipherDataModel in favor of more specific models. Optimizations to model transformations.
This commit is contained in:
@ -18,12 +18,24 @@ namespace Bit.Api.Models
|
||||
Type = cipher.Type;
|
||||
Data = cipher.Data;
|
||||
RevisionDate = cipher.RevisionDate;
|
||||
|
||||
switch(cipher.Type)
|
||||
{
|
||||
case Core.Enums.CipherType.Folder:
|
||||
Data = new FolderDataModel(cipher);
|
||||
break;
|
||||
case Core.Enums.CipherType.Site:
|
||||
Data = new SiteDataModel(cipher);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string FolderId { get; set; }
|
||||
public Core.Enums.CipherType Type { get; set; }
|
||||
public string Data { get; set; }
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
public dynamic Data { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Bit.Core.Domains;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Bit.Api.Models
|
||||
{
|
||||
@ -19,7 +18,7 @@ namespace Bit.Api.Models
|
||||
throw new ArgumentException(nameof(cipher.Type));
|
||||
}
|
||||
|
||||
var data = JsonConvert.DeserializeObject<CipherDataModel>(cipher.Data);
|
||||
var data = new FolderDataModel(cipher);
|
||||
|
||||
Id = cipher.Id.ToString();
|
||||
Name = data.Name;
|
||||
|
@ -19,7 +19,7 @@ namespace Bit.Api.Models
|
||||
throw new ArgumentException(nameof(cipher.Type));
|
||||
}
|
||||
|
||||
var data = JsonConvert.DeserializeObject<CipherDataModel>(cipher.Data);
|
||||
var data = new SiteDataModel(cipher);
|
||||
|
||||
Id = cipher.Id.ToString();
|
||||
FolderId = cipher.FolderId?.ToString();
|
||||
|
Reference in New Issue
Block a user