mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Handling notifications event and rendering them through controller
This commit is contained in:
@@ -3,19 +3,46 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Data;
|
||||
using BTCPayServer.Events;
|
||||
using BTCPayServer.Events.Notifications;
|
||||
using ExchangeSharp;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BTCPayServer.Models.NotificationViewModels
|
||||
{
|
||||
public class IndexViewModel
|
||||
{
|
||||
public List<NoticeDataHolder> Items { get; set; }
|
||||
public List<NotificationViewModel> Items { get; set; }
|
||||
}
|
||||
|
||||
public class NoticeDataHolder
|
||||
public class NotificationViewModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public DateTimeOffset Created { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string ActionLink { get; set; }
|
||||
}
|
||||
|
||||
public static class NotificationViewModelExt
|
||||
{
|
||||
public static NotificationViewModel ViewModel(this NotificationData data)
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string Level { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
if (data.NotificationType == nameof(NewVersionNotification))
|
||||
{
|
||||
var casted = JsonConvert.DeserializeObject<NewVersionNotification>(data.Blob.ToStringFromUTF8());
|
||||
var obj = new NotificationViewModel
|
||||
{
|
||||
Id = data.Id,
|
||||
Created = data.Created,
|
||||
Body = $"New version {casted.Version} released!",
|
||||
ActionLink = "https://github.com/btcpayserver/btcpayserver/releases/tag/v" + casted.Version
|
||||
};
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user