mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Branding updates for 2.0 (#5947)
* Remove deprecated CSS options Closes #5945. * Greenfield: Add brandColor to store APIs Closes #5946. * Migrate file IDs to URLs Closes #5953. * Greenfield: Add CSS and logo URL to store settings API Closes #5945. * Add migration test * Store and Server branding can reference file's via fileid:ID * Add PaymentSoundUrl to Store API --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
@@ -116,6 +116,10 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
Name = data.StoreName,
|
||||
Website = data.StoreWebsite,
|
||||
Archived = data.Archived,
|
||||
BrandColor = storeBlob.BrandColor,
|
||||
CssUrl = storeBlob.CssUrl?.ToString(),
|
||||
LogoUrl = storeBlob.LogoUrl?.ToString(),
|
||||
PaymentSoundUrl = storeBlob.PaymentSoundUrl?.ToString(),
|
||||
SupportUrl = storeBlob.StoreSupportUrl,
|
||||
SpeedPolicy = data.SpeedPolicy,
|
||||
DefaultPaymentMethod = data.GetDefaultPaymentId()?.ToString(),
|
||||
@@ -192,6 +196,10 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
blob.LightningDescriptionTemplate = restModel.LightningDescriptionTemplate;
|
||||
blob.PaymentTolerance = restModel.PaymentTolerance;
|
||||
blob.PayJoinEnabled = restModel.PayJoinEnabled;
|
||||
blob.BrandColor = restModel.BrandColor;
|
||||
blob.LogoUrl = restModel.LogoUrl is null ? null : UnresolvedUri.Create(restModel.LogoUrl);
|
||||
blob.CssUrl = restModel.CssUrl is null ? null : UnresolvedUri.Create(restModel.CssUrl);
|
||||
blob.PaymentSoundUrl = restModel.PaymentSoundUrl is null ? null : UnresolvedUri.Create(restModel.PaymentSoundUrl);
|
||||
if (restModel.AutoDetectLanguage.HasValue)
|
||||
blob.AutoDetectLanguage = restModel.AutoDetectLanguage.Value;
|
||||
if (restModel.ShowPayInWalletButton.HasValue)
|
||||
@@ -237,6 +245,18 @@ namespace BTCPayServer.Controllers.Greenfield
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.Website), "Website is not a valid url");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(request.LogoUrl) && !Uri.TryCreate(request.LogoUrl, UriKind.Absolute, out _))
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.LogoUrl), "Logo is not a valid url");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(request.CssUrl) && !Uri.TryCreate(request.CssUrl, UriKind.Absolute, out _))
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.CssUrl), "CSS is not a valid url");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(request.BrandColor) && !ColorPalette.IsValid(request.BrandColor))
|
||||
{
|
||||
ModelState.AddModelError(nameof(request.BrandColor), "Brand color is not a valid HEX Color (e.g. #F7931A)");
|
||||
}
|
||||
if (request.InvoiceExpiration < TimeSpan.FromMinutes(1) && request.InvoiceExpiration > TimeSpan.FromMinutes(60 * 24 * 24))
|
||||
ModelState.AddModelError(nameof(request.InvoiceExpiration), "InvoiceExpiration can only be between 1 and 34560 mins");
|
||||
if (request.DisplayExpirationTimer < TimeSpan.FromMinutes(1) && request.DisplayExpirationTimer > TimeSpan.FromMinutes(60 * 24 * 24))
|
||||
|
||||
Reference in New Issue
Block a user