diff --git a/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs b/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs index 8d5ae8cf2..093b1cde0 100644 --- a/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs +++ b/BTCPayServer/Models/NotificationViewModels/IndexViewModel.cs @@ -36,9 +36,8 @@ namespace BTCPayServer.Models.NotificationViewModels var fullTypeName = baseType.FullName.Replace(nameof(BaseNotification), data.NotificationType, StringComparison.OrdinalIgnoreCase); var parsedType = baseType.Assembly.GetType(fullTypeName); - var instance = Activator.CreateInstance(parsedType) as BaseNotification; - var casted = JsonConvert.DeserializeObject(ZipUtils.Unzip(data.Blob), parsedType); + var casted = (BaseNotification)JsonConvert.DeserializeObject(ZipUtils.Unzip(data.Blob), parsedType); var obj = new NotificationViewModel { Id = data.Id, @@ -46,7 +45,7 @@ namespace BTCPayServer.Models.NotificationViewModels Seen = data.Seen }; - instance.FillViewModel(obj); + casted.FillViewModel(ref obj); return obj; } diff --git a/BTCPayServer/Services/Notifications/Blobs/BaseNotification.cs b/BTCPayServer/Services/Notifications/Blobs/BaseNotification.cs index 38b45d8e8..36dd822e7 100644 --- a/BTCPayServer/Services/Notifications/Blobs/BaseNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/BaseNotification.cs @@ -27,6 +27,6 @@ namespace BTCPayServer.Services.Notifications.Blobs return data; } - public abstract void FillViewModel(NotificationViewModel data); + public abstract void FillViewModel(ref NotificationViewModel data); } } diff --git a/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs b/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs index 465eda090..f6bab8d6d 100644 --- a/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs +++ b/BTCPayServer/Services/Notifications/Blobs/NewVersionNotification.cs @@ -10,7 +10,7 @@ namespace BTCPayServer.Services.Notifications.Blobs public string Version { get; set; } - public override void FillViewModel(NotificationViewModel vm) + public override void FillViewModel(ref NotificationViewModel vm) { vm.Body = $"New version {Version} released!"; vm.ActionLink = $"https://github.com/btcpayserver/btcpayserver/releases/tag/v{Version}";