Set new store hints consistently for API and GUI

closes #2434
This commit is contained in:
Umar Bolatov
2021-04-05 21:24:34 -07:00
parent bbe1442c28
commit f0ac7d2c16

View File

@@ -159,6 +159,17 @@ namespace BTCPayServer.Services.Stores
}
}
private void SetNewStoreHints(ref StoreData storeData)
{
var blob = storeData.GetStoreBlob();
blob.Hints = new Data.StoreBlob.StoreHints
{
Wallet = true,
Lightning = true
};
storeData.SetStoreBlob(blob);
}
public async Task CreateStore(string ownerId, StoreData storeData)
{
if (!string.IsNullOrEmpty(storeData.Id))
@@ -176,6 +187,9 @@ namespace BTCPayServer.Services.Stores
ApplicationUserId = ownerId,
Role = StoreRoles.Owner,
};
SetNewStoreHints(ref storeData);
ctx.Add(storeData);
ctx.Add(userStore);
await ctx.SaveChangesAsync();
@@ -185,13 +199,7 @@ namespace BTCPayServer.Services.Stores
public async Task<StoreData> CreateStore(string ownerId, string name)
{
var store = new StoreData() { StoreName = name };
var blob = store.GetStoreBlob();
blob.Hints = new Data.StoreBlob.StoreHints
{
Wallet = true,
Lightning = true
};
store.SetStoreBlob(blob);
SetNewStoreHints(ref store);
await CreateStore(ownerId, store);
return store;
}