2021-12-31 16:59:02 +09:00
|
|
|
using System.Linq;
|
2021-11-26 16:13:41 +02:00
|
|
|
using BTCPayServer.Data;
|
|
|
|
using BTCPayServer.Services.Invoices;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
namespace BTCPayServer
|
|
|
|
{
|
|
|
|
public static class UserExtensions
|
|
|
|
{
|
2021-12-31 16:59:02 +09:00
|
|
|
public static UserBlob GetBlob(this ApplicationUser user)
|
|
|
|
{
|
|
|
|
var result = user.Blob == null
|
|
|
|
? new UserBlob()
|
|
|
|
: JObject.Parse(ZipUtils.Unzip(user.Blob)).ToObject<UserBlob>();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
public static bool SetBlob(this ApplicationUser user, UserBlob blob)
|
|
|
|
{
|
|
|
|
var newBytes = InvoiceRepository.ToBytes(blob);
|
|
|
|
if (user.Blob != null && newBytes.SequenceEqual(user.Blob))
|
2021-11-26 16:13:41 +02:00
|
|
|
{
|
2021-12-31 16:59:02 +09:00
|
|
|
return false;
|
2021-11-26 16:13:41 +02:00
|
|
|
}
|
2021-12-31 16:59:02 +09:00
|
|
|
user.Blob = newBytes;
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-26 16:13:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public class UserBlob
|
|
|
|
{
|
|
|
|
public bool ShowInvoiceStatusChangeHint { get; set; }
|
|
|
|
}
|
|
|
|
}
|