From fca3480e3747b39204df547379b56e65493df462 Mon Sep 17 00:00:00 2001 From: Chukwuleta Tobechi <47084273+TChukwuleta@users.noreply.github.com> Date: Tue, 19 Mar 2024 15:04:09 +0100 Subject: [PATCH] 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 --- BTCPayServer/Controllers/UIServerController.cs | 15 +++++++++++++-- BTCPayServer/Controllers/UIStoresController.cs | 2 +- BTCPayServer/Views/UIServer/Branding.cshtml | 5 ++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/BTCPayServer/Controllers/UIServerController.cs b/BTCPayServer/Controllers/UIServerController.cs index 80e55bb47..3714e7678 100644 --- a/BTCPayServer/Controllers/UIServerController.cs +++ b/BTCPayServer/Controllers/UIServerController.cs @@ -1049,11 +1049,22 @@ namespace BTCPayServer.Controllers vm.LogoFileId = theme.LogoFileId; vm.CustomThemeFileId = theme.CustomThemeFileId; - if (server.ServerName != vm.ServerName || server.ContactUrl != vm.ContactUrl) + if (server.ServerName != vm.ServerName) { server.ServerName = vm.ServerName; - server.ContactUrl = vm.ContactUrl; 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); } diff --git a/BTCPayServer/Controllers/UIStoresController.cs b/BTCPayServer/Controllers/UIStoresController.cs index cf57413f3..b1b986ec6 100644 --- a/BTCPayServer/Controllers/UIStoresController.cs +++ b/BTCPayServer/Controllers/UIStoresController.cs @@ -548,7 +548,7 @@ namespace BTCPayServer.Controllers blob.CustomLogo = model.CustomLogo; blob.CustomCSS = model.CustomCSS; 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.AutoDetectLanguage = model.AutoDetectLanguage; blob.DefaultLang = model.DefaultLang; diff --git a/BTCPayServer/Views/UIServer/Branding.cshtml b/BTCPayServer/Views/UIServer/Branding.cshtml index 78d63f7e1..c0387f4c4 100644 --- a/BTCPayServer/Views/UIServer/Branding.cshtml +++ b/BTCPayServer/Views/UIServer/Branding.cshtml @@ -28,9 +28,8 @@
- Contact link for support requests related to this BTCPay Server instance. - This link will appear on public facing pages. - Can be any valid URI, such as a website, email, and Nostr. + Add an email address or an external URL where users can contact you for support requests + through a "Contact Us" button, displayed at the bottom of the public facing pages.