mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
attachment models
This commit is contained in:
parent
87798612a6
commit
7c6c36b744
2 changed files with 83 additions and 0 deletions
59
src/Core/Models/Domain/Attachment.cs
Normal file
59
src/Core/Models/Domain/Attachment.cs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
using Bit.Core.Models.Data;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.Domain
|
||||||
|
{
|
||||||
|
public class Attachment : Domain
|
||||||
|
{
|
||||||
|
public Attachment() { }
|
||||||
|
|
||||||
|
public Attachment(AttachmentData obj, bool alreadyEncrypted = false)
|
||||||
|
{
|
||||||
|
Size = obj.Size;
|
||||||
|
BuildDomainModel(this, obj, new HashSet<string>
|
||||||
|
{
|
||||||
|
"Id",
|
||||||
|
"Url",
|
||||||
|
"SizeName",
|
||||||
|
"FileName",
|
||||||
|
"Key"
|
||||||
|
}, alreadyEncrypted, new HashSet<string> { "Id", "Url", "SizeName" });
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
public CipherString Key { get; set; }
|
||||||
|
public CipherString FileName { get; set; }
|
||||||
|
|
||||||
|
public async Task<AttachmentView> DecryptAsync(string orgId)
|
||||||
|
{
|
||||||
|
var view = await DecryptObjAsync(new AttachmentView(this), this, new HashSet<string>
|
||||||
|
{
|
||||||
|
"FileName"
|
||||||
|
}, orgId);
|
||||||
|
|
||||||
|
// TODO: Decrypt key
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttachmentData ToAttachmentData()
|
||||||
|
{
|
||||||
|
var a = new AttachmentData();
|
||||||
|
a.Size = Size;
|
||||||
|
BuildDataModel(this, a, new HashSet<string>
|
||||||
|
{
|
||||||
|
"Id",
|
||||||
|
"Url",
|
||||||
|
"SizeName",
|
||||||
|
"FileName",
|
||||||
|
"Key"
|
||||||
|
}, new HashSet<string> { "Id", "Url", "SizeName" });
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
src/Core/Models/View/AttachmentView.cs
Normal file
24
src/Core/Models/View/AttachmentView.cs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
using Bit.Core.Models.Domain;
|
||||||
|
|
||||||
|
namespace Bit.Core.Models.View
|
||||||
|
{
|
||||||
|
public class AttachmentView : View
|
||||||
|
{
|
||||||
|
public AttachmentView() { }
|
||||||
|
|
||||||
|
public AttachmentView(Attachment a)
|
||||||
|
{
|
||||||
|
Id = a.Id;
|
||||||
|
Url = a.Url;
|
||||||
|
Size = a.Size;
|
||||||
|
SizeName = a.SizeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
|
public string Url { get; set; }
|
||||||
|
public string Size { get; set; }
|
||||||
|
public string SizeName { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public SymmetricCryptoKey Key { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue