diff --git a/BTCPayServer.Client/Models/CreateAppRequest.cs b/BTCPayServer.Client/Models/CreateAppRequest.cs index d0fb101bc..11773a16c 100644 --- a/BTCPayServer.Client/Models/CreateAppRequest.cs +++ b/BTCPayServer.Client/Models/CreateAppRequest.cs @@ -35,13 +35,11 @@ namespace BTCPayServer.Client.Models public string CustomAmountPayButtonText { get; set; } = null; public string FixedAmountPayButtonText { get; set; } = null; public string TipText { get; set; } = null; - public string CustomCSSLink { get; set; } = null; public string NotificationUrl { get; set; } = null; public string RedirectUrl { get; set; } = null; public bool? RedirectAutomatically { get; set; } = null; public bool? Archived { get; set; } = null; public string FormId { get; set; } = null; - public string EmbeddedCSS { get; set; } = null; } public enum CrowdfundResetEvery @@ -65,9 +63,7 @@ namespace BTCPayServer.Client.Models [JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))] public DateTimeOffset? EndDate { get; set; } = null; public decimal? TargetAmount { get; set; } = null; - public string CustomCSSLink { get; set; } = null; public string MainImageUrl { get; set; } = null; - public string EmbeddedCSS { get; set; } = null; public string NotificationUrl { get; set; } = null; public string Tagline { get; set; } = null; public string PerksTemplate { get; set; } = null; diff --git a/BTCPayServer.Client/Models/PaymentRequestBaseData.cs b/BTCPayServer.Client/Models/PaymentRequestBaseData.cs index e34808790..8f6c2ee60 100644 --- a/BTCPayServer.Client/Models/PaymentRequestBaseData.cs +++ b/BTCPayServer.Client/Models/PaymentRequestBaseData.cs @@ -17,9 +17,6 @@ namespace BTCPayServer.Client.Models public string Title { get; set; } public string Description { get; set; } public string Email { get; set; } - - public string EmbeddedCSS { get; set; } - public string CustomCSSLink { get; set; } public bool AllowCustomPaymentAmounts { get; set; } [JsonExtensionData] diff --git a/BTCPayServer.Client/Models/PointOfSaleAppData.cs b/BTCPayServer.Client/Models/PointOfSaleAppData.cs index 1d013f1bb..ebc7d79c7 100644 --- a/BTCPayServer.Client/Models/PointOfSaleAppData.cs +++ b/BTCPayServer.Client/Models/PointOfSaleAppData.cs @@ -30,11 +30,9 @@ namespace BTCPayServer.Client.Models public string FixedAmountPayButtonText { get; set; } public string CustomAmountPayButtonText { get; set; } public string TipText { get; set; } - public string CustomCSSLink { get; set; } public string NotificationUrl { get; set; } public string RedirectUrl { get; set; } public string Description { get; set; } - public string EmbeddedCSS { get; set; } public bool? RedirectAutomatically { get; set; } } @@ -50,9 +48,7 @@ namespace BTCPayServer.Client.Models [JsonConverter(typeof(NBitcoin.JsonConverters.DateTimeToUnixTimeConverter))] public DateTimeOffset? EndDate { get; set; } public decimal? TargetAmount { get; set; } - public string CustomCSSLink { get; set; } public string MainImageUrl { get; set; } - public string EmbeddedCSS { get; set; } public string NotificationUrl { get; set; } public string Tagline { get; set; } public object Perks { get; set; } diff --git a/BTCPayServer.Client/Models/StoreBaseData.cs b/BTCPayServer.Client/Models/StoreBaseData.cs index 3ff83909d..7ebe05215 100644 --- a/BTCPayServer.Client/Models/StoreBaseData.cs +++ b/BTCPayServer.Client/Models/StoreBaseData.cs @@ -16,6 +16,11 @@ namespace BTCPayServer.Client.Models public string Website { get; set; } + public string BrandColor { get; set; } + public string LogoUrl { get; set; } + public string CssUrl { get; set; } + public string PaymentSoundUrl { get; set; } + public string SupportUrl { get; set; } [JsonConverter(typeof(TimeSpanJsonConverter.Seconds))] diff --git a/BTCPayServer.Data/Migrations/20240508015052_fileid.cs b/BTCPayServer.Data/Migrations/20240508015052_fileid.cs new file mode 100644 index 000000000..9f6e7b4a9 --- /dev/null +++ b/BTCPayServer.Data/Migrations/20240508015052_fileid.cs @@ -0,0 +1,61 @@ +using BTCPayServer.Data; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BTCPayServer.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240508015052_fileid")] + public partial class fileid : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(""" +UPDATE "Settings" +SET "Value" = jsonb_set( + "Value", + '{LogoUrl}', + to_jsonb('fileid:' || ("Value"->>'LogoFileId'))) - 'LogoFileId' +WHERE "Id" = 'BTCPayServer.Services.ThemeSettings' +AND "Value"->>'LogoFileId' IS NOT NULL; + +UPDATE "Settings" +SET "Value" = jsonb_set( + "Value", + '{CustomThemeCssUrl}', + to_jsonb('fileid:' || ("Value"->>'CustomThemeFileId'))) - 'CustomThemeFileId' +WHERE "Id" = 'BTCPayServer.Services.ThemeSettings' +AND "Value"->>'CustomThemeFileId' IS NOT NULL; + +UPDATE "Stores" +SET "StoreBlob" = jsonb_set( + "StoreBlob", + '{logoUrl}', + to_jsonb('fileid:' || ("StoreBlob"->>'logoFileId'))) - 'logoFileId' +WHERE "StoreBlob"->>'logoFileId' IS NOT NULL; + +UPDATE "Stores" +SET "StoreBlob" = jsonb_set( + "StoreBlob", + '{cssUrl}', + to_jsonb('fileid:' || ("StoreBlob"->>'cssFileId'))) - 'cssFileId' +WHERE "StoreBlob"->>'cssFileId' IS NOT NULL; + +UPDATE "Stores" +SET "StoreBlob" = jsonb_set( + "StoreBlob", + '{paymentSoundUrl}', + to_jsonb('fileid:' || ("StoreBlob"->>'soundFileId'))) - 'soundFileId' +WHERE "StoreBlob"->>'soundFileId' IS NOT NULL; +"""); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + } + } +} diff --git a/BTCPayServer.Tests/BTCPayServerTester.cs b/BTCPayServer.Tests/BTCPayServerTester.cs index 3f0997b10..fb43b342d 100644 --- a/BTCPayServer.Tests/BTCPayServerTester.cs +++ b/BTCPayServer.Tests/BTCPayServerTester.cs @@ -64,6 +64,11 @@ namespace BTCPayServer.Tests get; set; } + public Uri ServerUriWithIP + { + get; + set; + } public string MySQL { @@ -164,6 +169,7 @@ namespace BTCPayServer.Tests await File.WriteAllTextAsync(confPath, config.ToString()); ServerUri = new Uri("http://" + HostName + ":" + Port + "/"); + ServerUriWithIP = new Uri("http://127.0.0.1:" + Port + "/"); HttpClient = new HttpClient(); HttpClient.BaseAddress = ServerUri; Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development"); diff --git a/BTCPayServer.Tests/GreenfieldAPITests.cs b/BTCPayServer.Tests/GreenfieldAPITests.cs index 081295de2..b96aea5a9 100644 --- a/BTCPayServer.Tests/GreenfieldAPITests.cs +++ b/BTCPayServer.Tests/GreenfieldAPITests.cs @@ -1365,6 +1365,15 @@ namespace BTCPayServer.Tests //create store var newStore = await client.CreateStore(new CreateStoreRequest { Name = "A" }); Assert.Equal("A", newStore.Name); + + // validate + await AssertValidationError(["CssUrl", "LogoUrl", "BrandColor"], async () => + await client.UpdateStore(newStore.Id, new UpdateStoreRequest + { + CssUrl = "style.css", + LogoUrl = "logo.svg", + BrandColor = "invalid" + })); //update store Assert.Empty(newStore.PaymentMethodCriteria); @@ -1372,6 +1381,9 @@ namespace BTCPayServer.Tests var updatedStore = await client.UpdateStore(newStore.Id, new UpdateStoreRequest { Name = "B", + CssUrl = "https://example.org/style.css", + LogoUrl = "https://example.org/logo.svg", + BrandColor = "#003366", PaymentMethodCriteria = new List { new() @@ -1384,6 +1396,9 @@ namespace BTCPayServer.Tests } }); Assert.Equal("B", updatedStore.Name); + Assert.Equal("https://example.org/style.css", updatedStore.CssUrl); + Assert.Equal("https://example.org/logo.svg", updatedStore.LogoUrl); + Assert.Equal("#003366", updatedStore.BrandColor); var s = (await client.GetStore(newStore.Id)); Assert.Equal("B", s.Name); var pmc = Assert.Single(s.PaymentMethodCriteria); diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs index 8bb3bfd2e..c60073c7e 100644 --- a/BTCPayServer.Tests/TestAccount.cs +++ b/BTCPayServer.Tests/TestAccount.cs @@ -146,7 +146,7 @@ namespace BTCPayServer.Tests public async Task ModifyPayment(Action modify) { var storeController = GetController(); - var response = storeController.GeneralSettings(); + var response = await storeController.GeneralSettings(); GeneralSettingsViewModel settings = (GeneralSettingsViewModel)((ViewResult)response).Model; modify(settings); await storeController.GeneralSettings(settings); diff --git a/BTCPayServer.Tests/ThirdPartyTests.cs b/BTCPayServer.Tests/ThirdPartyTests.cs index 6821484dc..f211d43a5 100644 --- a/BTCPayServer.Tests/ThirdPartyTests.cs +++ b/BTCPayServer.Tests/ThirdPartyTests.cs @@ -57,7 +57,6 @@ namespace BTCPayServer.Tests Assert.IsType( await controller.EditAzureBlobStorageStorageProvider(azureBlobStorageConfiguration)); - var shouldBeRedirectingToAzureStorageConfigPage = Assert.IsType(await controller.Storage()); Assert.Equal(nameof(StorageProvider), shouldBeRedirectingToAzureStorageConfigPage.ActionName); @@ -72,9 +71,8 @@ namespace BTCPayServer.Tests await controller.StorageProvider(StorageProvider.AzureBlobStorage.ToString())) .Model).ConnectionString); - - - await UnitTest1.CanUploadRemoveFiles(controller); + var fileId = await UnitTest1.CanUploadFile(controller); + await UnitTest1.CanRemoveFile(controller, fileId); } [Fact(Skip = "Fail on CI")] diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index a4027482d..448036eab 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1,4 +1,5 @@ using System; +using Dapper; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -53,7 +54,6 @@ using BTCPayServer.Services.Rates; using BTCPayServer.Storage.Models; using BTCPayServer.Storage.Services.Providers.FileSystemStorage.Configuration; using BTCPayServer.Storage.ViewModels; -using ExchangeSharp; using Fido2NetLib; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -79,6 +79,7 @@ using CreatePaymentRequestRequest = BTCPayServer.Client.Models.CreatePaymentRequ using MarkPayoutRequest = BTCPayServer.Client.Models.MarkPayoutRequest; using PaymentRequestData = BTCPayServer.Client.Models.PaymentRequestData; using RatesViewModel = BTCPayServer.Models.StoreViewModels.RatesViewModel; +using Microsoft.Extensions.Caching.Memory; namespace BTCPayServer.Tests { @@ -297,7 +298,7 @@ namespace BTCPayServer.Tests // Set tolerance to 50% var stores = user.GetController(); - var response = stores.GeneralSettings(); + var response = await stores.GeneralSettings(); var vm = Assert.IsType(Assert.IsType(response).Model); Assert.Equal(0.0, vm.PaymentTolerance); vm.PaymentTolerance = 50.0; @@ -439,7 +440,7 @@ namespace BTCPayServer.Tests var user = tester.NewAccount(); await user.GrantAccessAsync(true); var storeController = user.GetController(); - var storeResponse = storeController.GeneralSettings(); + var storeResponse = await storeController.GeneralSettings(); Assert.IsType(storeResponse); Assert.IsType(storeController.SetupLightningNode(user.StoreId, "BTC")); @@ -838,7 +839,7 @@ namespace BTCPayServer.Tests var time = invoice.InvoiceTime; AssertSearchInvoice(acc, true, invoice.Id, $"startdate:{time.ToString("yyyy-MM-dd HH:mm:ss")}"); - AssertSearchInvoice(acc, true, invoice.Id, $"enddate:{time.ToStringLowerInvariant()}"); + AssertSearchInvoice(acc, true, invoice.Id, $"enddate:{time.ToString().ToLowerInvariant()}"); AssertSearchInvoice(acc, false, invoice.Id, $"startdate:{time.AddSeconds(1).ToString("yyyy-MM-dd HH:mm:ss")}"); AssertSearchInvoice(acc, false, invoice.Id, @@ -1499,8 +1500,7 @@ namespace BTCPayServer.Tests var btcMethod = PaymentTypes.CHAIN.GetPaymentMethodId("BTC").ToString(); // We allow BTC and LN, but not BTC under 5 USD, so only LN should be in the invoice - var vm = Assert.IsType(Assert - .IsType(user.GetController().CheckoutAppearance()).Model); + var vm = await user.GetController().CheckoutAppearance().AssertViewModelAsync(); Assert.Equal(2, vm.PaymentMethodCriteria.Count); var criteria = Assert.Single(vm.PaymentMethodCriteria.Where(m => m.PaymentMethod == btcMethod.ToString())); Assert.Equal(PaymentTypes.CHAIN.GetPaymentMethodId("BTC").ToString(), criteria.PaymentMethod); @@ -1527,8 +1527,7 @@ namespace BTCPayServer.Tests // Let's replicate https://github.com/btcpayserver/btcpayserver/issues/2963 // We allow BTC for more than 5 USD, and LN for less than 150. The default is LN, so the default // payment method should be LN. - vm = Assert.IsType(Assert - .IsType(user.GetController().CheckoutAppearance()).Model); + vm = await user.GetController().CheckoutAppearance().AssertViewModelAsync(); vm.DefaultPaymentMethod = lnMethod; criteria = vm.PaymentMethodCriteria.First(); criteria.Value = "150 USD"; @@ -1640,7 +1639,7 @@ namespace BTCPayServer.Tests user.GrantAccess(true); user.RegisterLightningNode(cryptoCode); user.SetLNUrl(cryptoCode, false); - var vm = user.GetController().CheckoutAppearance().AssertViewModel(); + var vm = await user.GetController().CheckoutAppearance().AssertViewModelAsync(); var criteria = Assert.Single(vm.PaymentMethodCriteria); Assert.Equal(PaymentTypes.LN.GetPaymentMethodId(cryptoCode).ToString(), criteria.PaymentMethod); criteria.Value = "2 USD"; @@ -1660,7 +1659,7 @@ namespace BTCPayServer.Tests // Activating LNUrl, we should still have only 1 payment criteria that can be set. user.RegisterLightningNode(cryptoCode); user.SetLNUrl(cryptoCode, true); - vm = user.GetController().CheckoutAppearance().AssertViewModel(); + vm = await user.GetController().CheckoutAppearance().AssertViewModelAsync(); criteria = Assert.Single(vm.PaymentMethodCriteria); Assert.Equal(PaymentTypes.LN.GetPaymentMethodId(cryptoCode).ToString(), criteria.PaymentMethod); Assert.IsType(user.GetController().CheckoutAppearance(vm).Result); @@ -2507,6 +2506,90 @@ namespace BTCPayServer.Tests } } + [Fact(Timeout = LongRunningTestTimeout)] + [Trait("Integration", "Integration")] + public async Task CanMigrateFileIds() + { + using var tester = CreateServerTester(newDb: true); + tester.DeleteStore = false; + await tester.StartAsync(); + + var user = tester.NewAccount(); + await user.GrantAccessAsync(); + + using (var ctx = tester.PayTester.GetService().CreateContext()) + { + var storeConfig = """ + { + "spread": 0.0, + "cssFileId": "2a51c49a-9d54-4013-80a2-3f6e69d08523", + "logoFileId": "8f890691-87f9-4c65-80e5-3b7ffaa3551f", + "soundFileId": "62bc4757-b92b-4a3b-a8ab-0e9b693d6a29", + "networkFeeMode": "MultiplePaymentsOnly", + "defaultCurrency": "USD", + "showStoreHeader": true, + "celebratePayment": true, + "paymentTolerance": 0.0, + "invoiceExpiration": 15, + "preferredExchange": "kraken", + "showRecommendedFee": true, + "monitoringExpiration": 1440, + "showPayInWalletButton": true, + "displayExpirationTimer": 5, + "excludedPaymentMethods": null, + "recommendedFeeBlockTarget": 1 + } + """; + var serverConfig = """ + { + "CssUri": null, + "FirstRun": false, + "LogoFileId": "ce71d90a-dd90-40a3-b1f0-96d00c9abb52", + "CustomTheme": true, + "CustomThemeCssUri": null, + "CustomThemeFileId": "9b00f4ed-914b-437b-abd2-9a90c1b22c34", + "CustomThemeExtension": 0 + } + """; + await ctx.Database.GetDbConnection().ExecuteAsync(""" + UPDATE "Stores" SET "StoreBlob"=@storeConfig::JSONB WHERE "Id"=@storeId; + """, new { storeId = user.StoreId, storeConfig }); + await ctx.Database.GetDbConnection().ExecuteAsync(""" + UPDATE "Settings" SET "Value"=@serverConfig::JSONB WHERE "Id"='BTCPayServer.Services.ThemeSettings'; + """, new { serverConfig }); + await ctx.Database.GetDbConnection().ExecuteAsync(""" + INSERT INTO "Files" VALUES (@id, @fileName, @id || '-' || @fileName, NOW(), @userId); + """, + new[] + { + new { id = "2a51c49a-9d54-4013-80a2-3f6e69d08523", fileName = "store.css", userId = user.UserId }, + new { id = "8f890691-87f9-4c65-80e5-3b7ffaa3551f", fileName = "store.png", userId = user.UserId }, + new { id = "ce71d90a-dd90-40a3-b1f0-96d00c9abb52", fileName = "admin.png", userId = user.UserId }, + new { id = "9b00f4ed-914b-437b-abd2-9a90c1b22c34", fileName = "admin.css", userId = user.UserId }, + new { id = "62bc4757-b92b-4a3b-a8ab-0e9b693d6a29", fileName = "store.mp3", userId = user.UserId }, + }); + await ctx.Database.GetDbConnection().ExecuteAsync(""" + DELETE FROM "__EFMigrationsHistory" WHERE "MigrationId"='20240508015052_fileid' + """); + await ctx.Database.MigrateAsync(); + ((MemoryCache)tester.PayTester.GetService()).Clear(); + } + + var controller = tester.PayTester.GetController(user.UserId, user.StoreId); + var vm = await controller.GeneralSettings().AssertViewModelAsync(); + Assert.Equal(tester.PayTester.ServerUriWithIP + "LocalStorage/8f890691-87f9-4c65-80e5-3b7ffaa3551f-store.png", vm.LogoUrl); + Assert.Equal(tester.PayTester.ServerUriWithIP + "LocalStorage/2a51c49a-9d54-4013-80a2-3f6e69d08523-store.css", vm.CssUrl); + + var vm2 = await controller.CheckoutAppearance().AssertViewModelAsync(); + Assert.Equal(tester.PayTester.ServerUriWithIP + "LocalStorage/62bc4757-b92b-4a3b-a8ab-0e9b693d6a29-store.mp3", vm2.PaymentSoundUrl); + + var serverController = tester.PayTester.GetController(); + var branding = await serverController.Branding().AssertViewModelAsync(); + + Assert.Equal(tester.PayTester.ServerUriWithIP + "LocalStorage/ce71d90a-dd90-40a3-b1f0-96d00c9abb52-admin.png", branding.LogoUrl); + Assert.Equal(tester.PayTester.ServerUriWithIP + "LocalStorage/9b00f4ed-914b-437b-abd2-9a90c1b22c34-admin.css", branding.CustomThemeCssUrl); + } + [Fact(Timeout = LongRunningTestTimeout)] [Trait("Integration", "Integration")] public async Task CanDoLightningInternalNodeMigration() @@ -2943,14 +3026,14 @@ namespace BTCPayServer.Tests Assert.Equal(StorageProvider.FileSystem, shouldBeRedirectingToLocalStorageConfigPage.RouteValues["provider"]); - await CanUploadRemoveFiles(controller); + var fileId = await CanUploadFile(controller); + await CanRemoveFile(controller, fileId); } - internal static async Task CanUploadRemoveFiles(UIServerController controller) + internal static async Task CanUploadFile(UIServerController controller) { var fileContent = "content"; - List fileList = new List(); - fileList.Add(TestUtils.GetFormFile("uploadtestfile1.txt", fileContent)); + var fileList = new List { TestUtils.GetFormFile("uploadtestfile1.txt", fileContent) }; var uploadFormFileResult = Assert.IsType(await controller.CreateFiles(fileList)); Assert.True(uploadFormFileResult.RouteValues.ContainsKey("fileIds")); @@ -2966,7 +3049,6 @@ namespace BTCPayServer.Tests Assert.True(viewFilesViewModel.DirectUrlByFiles.ContainsKey(fileId)); Assert.NotEmpty(viewFilesViewModel.DirectUrlByFiles[fileId]); - //verify file is available and the same using var net = new HttpClient(); var data = await net.GetStringAsync(new Uri(viewFilesViewModel.DirectUrlByFiles[fileId])); @@ -2991,17 +3073,20 @@ namespace BTCPayServer.Tests data = await net.GetStringAsync(new Uri(url)); Assert.Equal(fileContent, data); + return fileId; + } + internal static async Task CanRemoveFile(UIServerController controller, string fileId) + { //delete file Assert.IsType(await controller.DeleteFile(fileId)); - statusMessageModel = controller.TempData.GetStatusMessageModel(); + var statusMessageModel = controller.TempData.GetStatusMessageModel(); Assert.NotNull(statusMessageModel); - Assert.Equal(StatusMessageModel.StatusSeverity.Success, statusMessageModel.Severity); //attempt to fetch deleted file - viewFilesViewModel = - Assert.IsType(Assert.IsType(await controller.Files(new string[] { fileId })).Model); + var viewFilesViewModel = + Assert.IsType(Assert.IsType(await controller.Files([fileId])).Model); Assert.Null(viewFilesViewModel.DirectUrlByFiles); } diff --git a/BTCPayServer/Components/MainLogo/Default.cshtml b/BTCPayServer/Components/MainLogo/Default.cshtml index 1613fda34..275cbfb71 100644 --- a/BTCPayServer/Components/MainLogo/Default.cshtml +++ b/BTCPayServer/Components/MainLogo/Default.cshtml @@ -1,13 +1,12 @@ @using BTCPayServer.Services -@using BTCPayServer.Abstractions.Contracts @inject ThemeSettings Theme -@inject IFileService FileService +@inject UriResolver UriResolver @model BTCPayServer.Components.MainLogo.MainLogoViewModel -@if (!string.IsNullOrEmpty(Theme.LogoFileId)) +@if (Theme.LogoUrl is not null) { - var logoSrc = await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Theme.LogoFileId); - + var logoUrl = await UriResolver.Resolve(this.Context.Request.GetAbsoluteRootUri(), Theme.LogoUrl); + } else { diff --git a/BTCPayServer/Components/StoreSelector/Default.cshtml b/BTCPayServer/Components/StoreSelector/Default.cshtml index ceeb44d99..4d60fc92d 100644 --- a/BTCPayServer/Components/StoreSelector/Default.cshtml +++ b/BTCPayServer/Components/StoreSelector/Default.cshtml @@ -1,11 +1,8 @@ -@using BTCPayServer.Abstractions.Contracts -@using BTCPayServer.Client @using BTCPayServer.Components.MainLogo @using BTCPayServer.Services @using BTCPayServer.Views.Server @using BTCPayServer.Views.Stores @inject BTCPayServerEnvironment Env -@inject IFileService FileService @model BTCPayServer.Components.StoreSelector.StoreSelectorViewModel @functions { @* ReSharper disable once CSharpWarnings::CS1998 *@ @@ -39,9 +36,9 @@ else
- @* We are deprecating the custom CSS options in favor of the store branding approach. - Display this section only if these values are set. *@ - @if (!string.IsNullOrWhiteSpace(Model.CustomCSSLink) || !string.IsNullOrWhiteSpace(Model.EmbeddedCSS)) - { -
-

- -

-
-
-
- - - - - - -
-
- - - -
-
-
-
- } diff --git a/BTCPayServer/Views/Shared/LayoutHeadStoreBranding.cshtml b/BTCPayServer/Views/Shared/LayoutHeadStoreBranding.cshtml index 4bfd0d40c..da5877c2b 100644 --- a/BTCPayServer/Views/Shared/LayoutHeadStoreBranding.cshtml +++ b/BTCPayServer/Views/Shared/LayoutHeadStoreBranding.cshtml @@ -1,14 +1,4 @@ @model StoreBrandingViewModel -@using BTCPayServer.Abstractions.Contracts -@inject IFileService FileService -@{ - var logoUrl = !string.IsNullOrEmpty(Model.LogoFileId) - ? await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.LogoFileId) - : null; - var cssUrl = !string.IsNullOrEmpty(Model.CssFileId) - ? await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.CssFileId) - : null; -} @if (!string.IsNullOrEmpty(Model.BrandColor)) { var brand = Model.BrandColor; @@ -39,23 +29,12 @@ } -@if (!string.IsNullOrEmpty(cssUrl)) +@if (!string.IsNullOrEmpty(Model.CssUrl)) { - + } -@* Deprecated, but added for backwards-compatibility *@ -@if (!string.IsNullOrEmpty(Model.CustomCSSLink)) +@if (!string.IsNullOrEmpty(Model.LogoUrl)) { - -} -@if (!string.IsNullOrEmpty(Model.EmbeddedCSS)) -{ - -} -@if (!string.IsNullOrEmpty(logoUrl)) -{ - - + + } diff --git a/BTCPayServer/Views/Shared/LayoutHeadTheme.cshtml b/BTCPayServer/Views/Shared/LayoutHeadTheme.cshtml index 5bd9b9fe0..9db9abdb2 100644 --- a/BTCPayServer/Views/Shared/LayoutHeadTheme.cshtml +++ b/BTCPayServer/Views/Shared/LayoutHeadTheme.cshtml @@ -1,14 +1,9 @@ @using BTCPayServer.Services -@using BTCPayServer.Abstractions.Contracts @inject ThemeSettings Theme -@inject IFileService FileService +@inject UriResolver UriResolver -@if (Theme.CustomTheme && !string.IsNullOrEmpty(Theme.CssUri)) -{ // legacy customization with CSS URI - keep it for backwards-compatibility - -} -else if (Theme.CustomTheme && !string.IsNullOrEmpty(Theme.CustomThemeFileId)) +@if (Theme.CustomTheme && Theme.CustomThemeCssUrl is not null) { // new customization uses theme file id provided by upload @if (Theme.CustomThemeExtension != ThemeExtension.Custom) { // needs to be added for light and dark, because dark extends light @@ -17,8 +12,9 @@ else if (Theme.CustomTheme && !string.IsNullOrEmpty(Theme.CustomThemeFileId)) @if (Theme.CustomThemeExtension == ThemeExtension.Dark) { - } - + } + var themeUrl = await UriResolver.Resolve(this.Context.Request.GetAbsoluteRootUri(), Theme.CustomThemeCssUrl); + } else { diff --git a/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml b/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml index e85193c24..d126d9c22 100644 --- a/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml +++ b/BTCPayServer/Views/Shared/PointOfSale/UpdatePointOfSale.cshtml @@ -289,36 +289,6 @@ - @* We are deprecating the custom CSS options in favor of the store branding approach. - Display this section only if these values are set. *@ - @if (!string.IsNullOrWhiteSpace(Model.CustomCSSLink) || !string.IsNullOrWhiteSpace(Model.EmbeddedCSS)) - { -
-

- -

-
-
-
- - - - - - -
-
- - - -
-
-
-
- } diff --git a/BTCPayServer/Views/Shared/_StoreHeader.cshtml b/BTCPayServer/Views/Shared/_StoreHeader.cshtml index 3c4e95a47..41f64ce78 100644 --- a/BTCPayServer/Views/Shared/_StoreHeader.cshtml +++ b/BTCPayServer/Views/Shared/_StoreHeader.cshtml @@ -1,15 +1,9 @@ -@inject IFileService FileService -@using BTCPayServer.Abstractions.Contracts @model (string Title, StoreBrandingViewModel StoreBranding) -@{ - var logoUrl = !string.IsNullOrEmpty(Model.StoreBranding.LogoFileId) - ? await FileService.GetFileUrl(Context.Request.GetAbsoluteRootUri(), Model.StoreBranding.LogoFileId) - : null; -} +
- @if (!string.IsNullOrEmpty(logoUrl)) + @if (!string.IsNullOrEmpty(Model.StoreBranding.LogoUrl)) { - + }

@Model.Title

diff --git a/BTCPayServer/Views/UIForms/View.cshtml b/BTCPayServer/Views/UIForms/View.cshtml index 2bfe91109..b3c493b56 100644 --- a/BTCPayServer/Views/UIForms/View.cshtml +++ b/BTCPayServer/Views/UIForms/View.cshtml @@ -15,7 +15,7 @@
- @if (!string.IsNullOrEmpty(Model.StoreName) || !string.IsNullOrEmpty(Model.StoreBranding.LogoFileId)) + @if (!string.IsNullOrEmpty(Model.StoreName) || !string.IsNullOrEmpty(Model.StoreBranding.LogoUrl)) { } diff --git a/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml b/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml index 9f072ad29..5e7fe3c65 100644 --- a/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml +++ b/BTCPayServer/Views/UIPaymentRequest/EditPaymentRequest.cshtml @@ -123,46 +123,6 @@
- - @* We are deprecating the custom CSS options in favor of the store branding approach. - Display this section only if these values are set. *@ - @if (!string.IsNullOrWhiteSpace(Model.CustomCSSLink) || !string.IsNullOrWhiteSpace(Model.EmbeddedCSS)) - { -
-
-

Additional Options

-
-
-
-

- -

-
-
-
- - - - - - -
-
- - - -
-
-
-
-
-
-
-
- } @if (!string.IsNullOrEmpty(Model.Id)) diff --git a/BTCPayServer/Views/UIPullPayment/EditPullPayment.cshtml b/BTCPayServer/Views/UIPullPayment/EditPullPayment.cshtml index e748f7316..b2ce143b2 100644 --- a/BTCPayServer/Views/UIPullPayment/EditPullPayment.cshtml +++ b/BTCPayServer/Views/UIPullPayment/EditPullPayment.cshtml @@ -1,5 +1,4 @@ @using BTCPayServer.Views.Stores -@using BTCPayServer.Abstractions.Extensions @model BTCPayServer.Models.WalletViewModels.UpdatePullPaymentModel @{ @@ -53,44 +52,4 @@ - - @* We are deprecating the custom CSS options in favor of the store branding approach. - Display this section only if these values are set. *@ - @if (!string.IsNullOrWhiteSpace(Model.CustomCSSLink) || !string.IsNullOrWhiteSpace(Model.EmbeddedCSS)) - { -
-
-

Additional Options

-
-
-
-

- -

-
-
-
- - - - - - -
-
- - - -
-
-
-
-
-
-
-
- } diff --git a/BTCPayServer/Views/UIServer/Branding.cshtml b/BTCPayServer/Views/UIServer/Branding.cshtml index 223f8b373..2430c0043 100644 --- a/BTCPayServer/Views/UIServer/Branding.cshtml +++ b/BTCPayServer/Views/UIServer/Branding.cshtml @@ -36,7 +36,7 @@
- @if (!string.IsNullOrEmpty(Model.LogoFileId)) + @if (!string.IsNullOrEmpty(Model.LogoUrl)) {
- @if (!string.IsNullOrEmpty(Model.CustomThemeCssUri)) - { -
- - - +
+ + +
+
+
+ + @if (!string.IsNullOrEmpty(Model.CustomThemeCssUrl)) + { + + }
- } - else - { -
- - -
-
-
- - @if (!string.IsNullOrEmpty(Model.CustomThemeFileId)) + @if (canUpload) + { +
+ + @if (!string.IsNullOrEmpty(Model.CustomThemeCssUrl)) { - + Custom CSS }
- @if (canUpload) - { -
- - @if (!string.IsNullOrEmpty(Model.CustomThemeFileId)) - { - Custom CSS - } -
- - } - else - { - -

In order to upload a theme file, a file storage must be configured.

- } -
- } + + } + else + { + +

In order to upload a theme file, a file storage must be configured.

+ } +
diff --git a/BTCPayServer/Views/UIStorePullPayments/NewPullPayment.cshtml b/BTCPayServer/Views/UIStorePullPayments/NewPullPayment.cshtml index 2b64f9012..4aa229cd7 100644 --- a/BTCPayServer/Views/UIStorePullPayments/NewPullPayment.cshtml +++ b/BTCPayServer/Views/UIStorePullPayments/NewPullPayment.cshtml @@ -95,36 +95,6 @@
- @* We are deprecating the custom CSS options in favor of the store branding approach. - Display this section only if these values are set. *@ - @if (!string.IsNullOrWhiteSpace(Model.CustomCSSLink) || !string.IsNullOrWhiteSpace(Model.EmbeddedCSS)) - { -
-

- -

-
-
-
- - - - - - -
-
- - - -
-
-
-
- } diff --git a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml index eeaf9cc42..52a841448 100644 --- a/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml +++ b/BTCPayServer/Views/UIStores/CheckoutAppearance.cshtml @@ -143,7 +143,7 @@
- @if (!string.IsNullOrEmpty(Model.SoundFileId)) + @if (!string.IsNullOrEmpty(Model.PaymentSoundUrl)) {