From d3f95de5467fdd77a946e0f30d66da2485dfdb2b Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 28 Aug 2025 22:43:08 +0100 Subject: [PATCH] Wired up notification alert reward - untested #576 --- .../Helpers/NotifierHelper.cs | 18 ++++++++++++++++++ .../Helpers/RewardHelper.cs | 5 +++-- .../Models/Eft/Ws/WsNotificationPopup.cs | 16 ++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsNotificationPopup.cs diff --git a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs index a8b35245..7945ccb1 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/NotifierHelper.cs @@ -1,5 +1,6 @@ using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Models.Common; +using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Eft.Profile; using SPTarkov.Server.Core.Models.Eft.Ws; @@ -33,6 +34,23 @@ public class NotifierHelper(HttpServerHelper httpServerHelper) }; } + /// + /// Create a new notification that displays a message to the player - currently used by quests as a reward + /// + /// IllustrationConfig object from quest reward + /// Message Id from quest reward + /// WsNotificationPopup + public WsNotificationPopup CreateNotificationPopup(IllustrationConfig config, MongoId messageId) + { + return new WsNotificationPopup + { + EventType = NotificationEventType.NotificationPopup, + EventId = new MongoId(), + Image = config.BigImage, + Message = messageId, + }; + } + /// /// Create a new notification with the specified dialogueMessage object /// diff --git a/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs b/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs index c95bca29..4554bd0f 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs @@ -25,6 +25,7 @@ public class RewardHelper( ServerLocalisationService serverLocalisationService, TraderHelper traderHelper, PresetHelper presetHelper, + NotifierHelper notifierHelper, NotificationSendHelper notificationSendHelper, ICloner cloner ) @@ -130,8 +131,8 @@ public class RewardHelper( break; case RewardType.NotificationPopup: - // TODO: Wire up to notification system - logger.Error("UNHANDLED: RewardType.NotificationPopup"); + var notification = notifierHelper.CreateNotificationPopup(reward.IllustrationConfig, reward.Message.Value); + notificationSendHelper.SendMessage(sessionId.Value, notification); break; case RewardType.WebPromoCode: // TODO: ??? (Free arena trial from Balancing - Part 1) diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsNotificationPopup.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsNotificationPopup.cs new file mode 100644 index 00000000..71b9e17c --- /dev/null +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Ws/WsNotificationPopup.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; + +namespace SPTarkov.Server.Core.Models.Eft.Ws; + +public record WsNotificationPopup : WsNotificationEvent +{ + [JsonPropertyName("eventId")] + public MongoId EventId { get; set; } + + [JsonPropertyName("image")] + public string Image { get; set; } + + [JsonPropertyName("message")] + public MongoId Message { get; set; } +}