Email Rules: Require either recipients or customer email option (#5357)

This commit is contained in:
d11n 2023-09-28 08:36:12 +02:00 committed by GitHub
parent 44a7e9387e
commit 0cfb0ba890
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -62,6 +62,14 @@ namespace BTCPayServer.Controllers
return View(vm);
}
for (var i = 0; index < vm.Rules.Count; index++)
{
var rule = vm.Rules[i];
if (!rule.CustomerEmail && string.IsNullOrEmpty(rule.To))
ModelState.AddModelError($"{nameof(vm.Rules)}[{i}].{nameof(rule.To)}", "Either recipient or \"Send the email to the buyer\" is required");
}
if (!ModelState.IsValid)
{
return View(vm);
@ -121,7 +129,6 @@ namespace BTCPayServer.Controllers
public bool CustomerEmail { get; set; }
[Required]
[MailboxAddress]
public string To { get; set; }

View file

@ -60,7 +60,7 @@
<div class="form-text">Choose what event sends the email.</div>
</div>
<div class="form-group">
<label asp-for="Rules[index].To" class="form-label" data-required>Recipients</label>
<label asp-for="Rules[index].To" class="form-label">Recipients</label>
<input type="text" asp-for="Rules[index].To" class="form-control email-rule-to" />
<span asp-validation-for="Rules[index].To" class="text-danger"></span>
<div class="form-text">Who to send the email to. For multiple emails, separate with a comma.</div>