Specify mailto: prefix for emails in Server Settings (#5844)

* Specify mailto: prefix for emails in Server Settings

* resolve test failure

* Update wording

* Apply mailto-prefix on setting change

---------

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
Chukwuleta Tobechi 2024-03-19 15:04:09 +01:00 committed by GitHub
parent 966547db54
commit fca3480e37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 6 deletions

View file

@ -1049,11 +1049,22 @@ namespace BTCPayServer.Controllers
vm.LogoFileId = theme.LogoFileId; vm.LogoFileId = theme.LogoFileId;
vm.CustomThemeFileId = theme.CustomThemeFileId; vm.CustomThemeFileId = theme.CustomThemeFileId;
if (server.ServerName != vm.ServerName || server.ContactUrl != vm.ContactUrl) if (server.ServerName != vm.ServerName)
{ {
server.ServerName = vm.ServerName; server.ServerName = vm.ServerName;
server.ContactUrl = vm.ContactUrl;
settingsChanged = true; settingsChanged = true;
}
if (server.ContactUrl != vm.ContactUrl)
{
server.ContactUrl = !string.IsNullOrWhiteSpace(vm.ContactUrl)
? vm.ContactUrl.IsValidEmail() ? $"mailto:{vm.ContactUrl}" : vm.ContactUrl
: null;
settingsChanged = true;
}
if (settingsChanged)
{
await _SettingsRepository.UpdateSetting(server); await _SettingsRepository.UpdateSetting(server);
} }

View file

@ -548,7 +548,7 @@ namespace BTCPayServer.Controllers
blob.CustomLogo = model.CustomLogo; blob.CustomLogo = model.CustomLogo;
blob.CustomCSS = model.CustomCSS; blob.CustomCSS = model.CustomCSS;
blob.HtmlTitle = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle; blob.HtmlTitle = string.IsNullOrWhiteSpace(model.HtmlTitle) ? null : model.HtmlTitle;
blob.StoreSupportUrl = string.IsNullOrWhiteSpace(model.SupportUrl) ? null : model.SupportUrl; blob.StoreSupportUrl = string.IsNullOrWhiteSpace(model.SupportUrl) ? null : model.SupportUrl.IsValidEmail() ? $"mailto:{model.SupportUrl}" : model.SupportUrl;
blob.DisplayExpirationTimer = TimeSpan.FromMinutes(model.DisplayExpirationTimer); blob.DisplayExpirationTimer = TimeSpan.FromMinutes(model.DisplayExpirationTimer);
blob.AutoDetectLanguage = model.AutoDetectLanguage; blob.AutoDetectLanguage = model.AutoDetectLanguage;
blob.DefaultLang = model.DefaultLang; blob.DefaultLang = model.DefaultLang;

View file

@ -28,9 +28,8 @@
<label asp-for="ContactUrl" class="form-label"></label> <label asp-for="ContactUrl" class="form-label"></label>
<input asp-for="ContactUrl" class="form-control" /> <input asp-for="ContactUrl" class="form-control" />
<div class="form-text"> <div class="form-text">
Contact link for support requests related to this BTCPay Server instance. Add an email address or an external URL where users can contact you for support requests
This link will appear on public facing pages. through a "Contact Us" button, displayed at the bottom of the public facing pages.
Can be any valid URI, such as a website, email, and Nostr.
</div> </div>
<span asp-validation-for="ContactUrl" class="text-danger"></span> <span asp-validation-for="ContactUrl" class="text-danger"></span>
</div> </div>