More logging

This commit is contained in:
2024-01-13 22:50:42 +00:00
parent ed79445fe6
commit d080dbac04
2 changed files with 26 additions and 20 deletions

View File

@ -72,8 +72,7 @@ public class Lnurl
public async Task<LNURLService?> LoadAsync(string lnurl)
{
var url = ParseLnUrl(lnurl);
using var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
var response = await _client.GetAsync(url);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
@ -112,8 +111,7 @@ public class Lnurl
try
{
using var httpClient = new HttpClient();
var response = await httpClient.GetAsync(builder.Uri);
var response = await _client.GetAsync(builder.Uri);
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
@ -130,7 +128,7 @@ public class Lnurl
}
catch (Exception e)
{
throw new LNURLError(LNURLErrorCode.ServiceUnavailable, "Failed to load callback");
throw new LNURLError(LNURLErrorCode.ServiceUnavailable, $"Failed to load callback: {e.Message}");
}
}
}

View File

@ -137,6 +137,8 @@ public class ZapperRelay : INostrRelay, IDisposable
};
var zapSigned = zap.Sign(key);
try
{
var invoice = await _lnurl.GetInvoiceAsync(svc, 5, "Thanks for your interaction!", zapSigned);
if (string.IsNullOrEmpty(invoice.Pr))
{
@ -155,6 +157,12 @@ public class ZapperRelay : INostrRelay, IDisposable
_logger.LogInformation("Zapped {name}!", senderProfile.Name);
return new(true, "Zapped!");
}
catch (Exception e)
{
_logger.LogError(e.ToString());
return new(false, $"blocked: Oh no! something went wrong! {e.Message}");
}
}
return new(false, "blocked: kind not accepted, no zap for you!");
}