diff --git a/Libraries/Core/Controllers/GameController.cs b/Libraries/Core/Controllers/GameController.cs index 05499807..be4553e4 100644 --- a/Libraries/Core/Controllers/GameController.cs +++ b/Libraries/Core/Controllers/GameController.cs @@ -292,7 +292,7 @@ public class GameController( public GameKeepAliveResponse GetKeepAlive(string sessionId) { _profileActivityService.SetActivityTimestamp(sessionId); - return new GameKeepAliveResponse() { Message = "OK", UtcTime = _timeUtil.GetTimeStamp() }; + return new GameKeepAliveResponse { Message = "OK", UtcTime = _timeUtil.GetTimeStamp() }; } /// diff --git a/Libraries/Core/Services/MailSendService.cs b/Libraries/Core/Services/MailSendService.cs index 2a12e886..336a8749 100644 --- a/Libraries/Core/Services/MailSendService.cs +++ b/Libraries/Core/Services/MailSendService.cs @@ -102,7 +102,7 @@ public class MailSendService( */ public void SendLocalisedNpcMessageToPlayer( string sessionId, - string trader, + string? trader, MessageType messageType, string messageLocaleId, List? items, @@ -350,7 +350,7 @@ public class MailSendService( ProfileChangeEvents = (messageDetails.ProfileChangeEvents?.Count == 0) ? messageDetails.ProfileChangeEvents : null }; - // handle replyTo + // Handle replyTo if (messageDetails.ReplyTo is not null) { var replyMessage = GetMessageToReplyTo(messageDetails.RecipientId, messageDetails.ReplyTo, dialogId); @@ -548,30 +548,30 @@ public class MailSendService( */ private Dialogue GetDialog(SendMessageDetails messageDetails) { - var dialogsInProfile = _dialogueHelper.GetDialogsForProfile(messageDetails.RecipientId); var senderId = GetMessageSenderIdByType(messageDetails); if (senderId is null) + { throw new Exception(_localisationService.GetText("mail-unable_to_find_message_sender_by_id", messageDetails.Sender)); + } + + var dialogsInProfile = _dialogueHelper.GetDialogsForProfile(messageDetails.RecipientId); // Does dialog exist - var senderDialog = dialogsInProfile.FirstOrDefault(x => x.Key == senderId).Value; - if (senderDialog is null) + if (!dialogsInProfile.ContainsKey(senderId)) { - // create if doesnt - dialogsInProfile[senderId] = senderDialog = new Dialogue() + // Doesn't exist, create + dialogsInProfile[senderId] = new Dialogue { Id = senderId, - Type = (messageDetails.DialogType is not null) ? messageDetails.DialogType : messageDetails.Sender, - Messages = new(), + Type = messageDetails.DialogType ?? messageDetails.Sender, + Messages = [], Pinned = false, New = 0, AttachmentsNew = 0 }; - - senderDialog = dialogsInProfile[senderId]; } - return senderDialog; + return dialogsInProfile[senderId]; ; } /**