fix issues around local btcpay client and no request obj

This commit is contained in:
Kukks
2022-03-30 15:04:51 +02:00
parent 451eee549b
commit b0f00773d6
2 changed files with 18 additions and 2 deletions

View File

@@ -1,10 +1,12 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Client; using BTCPayServer.Client;
using Microsoft.AspNetCore.Http;
namespace BTCPayServer.Abstractions.Contracts namespace BTCPayServer.Abstractions.Contracts
{ {
public interface IBTCPayServerClientFactory public interface IBTCPayServerClientFactory
{ {
Task<BTCPayServerClient> Create(string userId, params string[] storeIds); Task<BTCPayServerClient> Create(string userId, params string[] storeIds);
Task<BTCPayServerClient> Create(string userId, string[] storeIds, HttpContext httpRequest);
} }
} }

View File

@@ -118,9 +118,23 @@ namespace BTCPayServer.Controllers.Greenfield
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
} }
public async Task<BTCPayServerClient> Create(string userId, params string[] storeIds) public Task<BTCPayServerClient> Create(string userId, params string[] storeIds)
{
return Create(userId, storeIds, new DefaultHttpContext()
{
Request =
{
Scheme = "https",
Host = new HostString("dummy.com"),
Path = new PathString(),
PathBase = new PathString(),
}
});
}
public async Task<BTCPayServerClient> Create(string userId, string[] storeIds, HttpContext context)
{ {
var context = new DefaultHttpContext();
if (!string.IsNullOrEmpty(userId)) if (!string.IsNullOrEmpty(userId))
{ {
var user = await _userManager.FindByIdAsync(userId); var user = await _userManager.FindByIdAsync(userId);