mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-26 07:23:06 +01:00
* Different icons for notifications Closes #2510. * Fix version appendix for SVG use attributes * Fix SVGUse TagHelper * Update icons
60 lines
2.4 KiB
C#
60 lines
2.4 KiB
C#
using System;
|
|
using BTCPayServer.Abstractions.Contracts;
|
|
using BTCPayServer.Client.Models;
|
|
using BTCPayServer.Configuration;
|
|
using BTCPayServer.Controllers;
|
|
using ExchangeSharp;
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
namespace BTCPayServer.Services.Notifications.Blobs
|
|
{
|
|
public class PayoutNotification : BaseNotification
|
|
{
|
|
private const string TYPE = "payout";
|
|
|
|
internal class Handler : NotificationHandler<PayoutNotification>
|
|
{
|
|
private readonly LinkGenerator _linkGenerator;
|
|
private readonly BTCPayServerOptions _options;
|
|
|
|
public Handler(LinkGenerator linkGenerator, BTCPayServerOptions options)
|
|
{
|
|
_linkGenerator = linkGenerator;
|
|
_options = options;
|
|
}
|
|
|
|
public override string NotificationType => TYPE;
|
|
public override (string identifier, string name)[] Meta
|
|
{
|
|
get
|
|
{
|
|
return new (string identifier, string name)[] { (TYPE, "Payouts") };
|
|
}
|
|
}
|
|
|
|
protected override void FillViewModel(PayoutNotification notification, NotificationViewModel vm)
|
|
{
|
|
vm.Identifier = notification.Identifier;
|
|
vm.Type = notification.NotificationType;
|
|
vm.Body = (notification.Status ?? PayoutState.AwaitingApproval) switch
|
|
{
|
|
PayoutState.AwaitingApproval => "A new payout is awaiting for approval",
|
|
PayoutState.AwaitingPayment => "A new payout is approved and awaiting payment",
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
};
|
|
vm.ActionLink = _linkGenerator.GetPathByAction(nameof(UIStorePullPaymentsController.Payouts),
|
|
"UIStorePullPayments",
|
|
new { storeId = notification.StoreId, paymentMethodId = notification.PaymentMethod }, _options.RootPath);
|
|
}
|
|
}
|
|
|
|
public string PayoutId { get; set; }
|
|
public string StoreId { get; set; }
|
|
public string PaymentMethod { get; set; }
|
|
public string Currency { get; set; }
|
|
public override string Identifier => Status is null ? TYPE : $"{TYPE}_{Status.ToStringLowerInvariant()}";
|
|
|
|
public override string NotificationType => TYPE;
|
|
public PayoutState? Status { get; set; }
|
|
}
|
|
}
|