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

@ -137,23 +137,31 @@ public class ZapperRelay : INostrRelay, IDisposable
};
var zapSigned = zap.Sign(key);
var invoice = await _lnurl.GetInvoiceAsync(svc, 5, "Thanks for your interaction!", zapSigned);
if (string.IsNullOrEmpty(invoice.Pr))
try
{
return new(false, $"blocked: failed to get invoice from {parsedTarget}");
}
var invoice = await _lnurl.GetInvoiceAsync(svc, 5, "Thanks for your interaction!", zapSigned);
if (string.IsNullOrEmpty(invoice.Pr))
{
return new(false, $"blocked: failed to get invoice from {parsedTarget}");
}
_logger.LogInformation("Paying invoice {pr}", invoice.Pr);
if (!await _albyApi.PayInvoice(invoice.Pr))
_logger.LogInformation("Paying invoice {pr}", invoice.Pr);
if (!await _albyApi.PayInvoice(invoice.Pr))
{
return new(false, "blocked: failed to pay invoice!");
}
var seenEvent = NostrBuf.Encode(ev);
(await _session.UpsertAsync(ref seenId, ref seenEvent)).Complete();
_logger.LogInformation("Zapped {name}!", senderProfile.Name);
return new(true, "Zapped!");
}
catch (Exception e)
{
return new(false, "blocked: failed to pay invoice!");
_logger.LogError(e.ToString());
return new(false, $"blocked: Oh no! something went wrong! {e.Message}");
}
var seenEvent = NostrBuf.Encode(ev);
(await _session.UpsertAsync(ref seenId, ref seenEvent)).Complete();
_logger.LogInformation("Zapped {name}!", senderProfile.Name);
return new(true, "Zapped!");
}
return new(false, "blocked: kind not accepted, no zap for you!");