Webhooks: Fix invoice interpolation (#5586)

* Webhooks: Fix invoice interpolation

Fixes #5584.

* Syntax cleanups
This commit is contained in:
d11n 2023-12-22 02:50:08 +01:00 committed by GitHub
parent ad89139e07
commit c585a0b276
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 12 deletions

View file

@ -59,15 +59,12 @@ public class StoreEmailRuleProcessorSender : EventHostedServiceBase
var sender = await _emailSenderFactory.GetEmailSender(storeWebhookEvent.StoreId); var sender = await _emailSenderFactory.GetEmailSender(storeWebhookEvent.StoreId);
foreach (UIStoresController.StoreEmailRule actionableRule in actionableRules) foreach (UIStoresController.StoreEmailRule actionableRule in actionableRules)
{ {
var request = new SendEmailRequest
var request = new SendEmailRequest()
{ {
Subject = actionableRule.Subject, Body = actionableRule.Body, Email = actionableRule.To Subject = actionableRule.Subject, Body = actionableRule.Body, Email = actionableRule.To
}; };
request = await webhookDeliveryRequest.Interpolate(request, actionableRule); request = await webhookDeliveryRequest.Interpolate(request, actionableRule);
var recipients = (request?.Email?.Split(",", StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty<string>()) var recipients = (request?.Email?.Split(",", StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty<string>())
.Select(o => .Select(o =>
{ {

View file

@ -1,11 +1,9 @@
using System; using System.Globalization;
using System.Globalization;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Client.Models; using BTCPayServer.Client.Models;
using BTCPayServer.Controllers; using BTCPayServer.Controllers;
using BTCPayServer.Data; using BTCPayServer.Data;
using BTCPayServer.Services.Invoices; using BTCPayServer.Services.Invoices;
using Newtonsoft.Json.Linq;
using WebhookDeliveryData = BTCPayServer.Data.WebhookDeliveryData; using WebhookDeliveryData = BTCPayServer.Data.WebhookDeliveryData;
namespace BTCPayServer.HostedServices.Webhooks; namespace BTCPayServer.HostedServices.Webhooks;
@ -46,7 +44,7 @@ public class InvoiceWebhookDeliveryRequest : WebhookSender.WebhookDeliveryReques
.Replace("{Invoice.OrderId}", Invoice.Metadata.OrderId); .Replace("{Invoice.OrderId}", Invoice.Metadata.OrderId);
res = InterpolateJsonField(str, "Invoice.Metadata", Invoice.Metadata.ToJObject()); res = InterpolateJsonField(res, "Invoice.Metadata", Invoice.Metadata.ToJObject());
return res; return res;
} }