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; namespace SPTarkov.Server.Core.Helpers; [Injectable(InjectionType.Singleton)] public class NotifierHelper(HttpServerHelper httpServerHelper) { protected static readonly WsPing Ping = new(); public WsNotificationEvent GetDefaultNotification() { return Ping; } /// /// Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside /// /// Message from dialog that was sent /// Ragfair data to attach to notification /// public WsRagfairOfferSold CreateRagfairOfferSoldNotification(Message dialogueMessage, MessageContentRagfair ragfairData) { return new WsRagfairOfferSold { EventType = NotificationEventType.RagfairOfferSold, EventIdentifier = dialogueMessage.Id, OfferId = ragfairData.OfferId, HandbookId = ragfairData.HandbookId, Count = Convert.ToInt32(ragfairData.Count), }; } /// /// 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 /// /// /// WsChatMessageReceived public WsChatMessageReceived CreateNewMessageNotification(Message dialogueMessage) { return new WsChatMessageReceived { EventType = NotificationEventType.new_message, EventIdentifier = dialogueMessage.Id, DialogId = dialogueMessage.UserId, Message = dialogueMessage, }; } /// /// Create a new rating ragfair notification /// /// new rating /// Rating is going up /// WsRagfairNewRating public WsRagfairNewRating CreateRagfairNewRatingNotification(double rating, bool isGrowing) { return new WsRagfairNewRating { EventType = NotificationEventType.RagfairNewRating, EventIdentifier = new MongoId(), Rating = rating, IsRatingGrowing = isGrowing, }; } /// /// Get the web socket server URI /// /// Player/Session id /// URI as string public string GetWebSocketServer(MongoId sessionId) { return $"{httpServerHelper.GetWebsocketUrl()}/notifierServer/getwebsocket/{sessionId.ToString()}"; } }