diff --git a/Core/Callbacks/DialogueCallbacks.cs b/Core/Callbacks/DialogueCallbacks.cs
index b6180142..b1fc5ab8 100644
--- a/Core/Callbacks/DialogueCallbacks.cs
+++ b/Core/Callbacks/DialogueCallbacks.cs
@@ -1,4 +1,4 @@
-using Core.Annotations;
+using Core.Annotations;
using Core.Controllers;
using Core.DI;
using Core.Models.Eft.Common;
diff --git a/Core/Controllers/DialogueController.cs b/Core/Controllers/DialogueController.cs
index cd7d0e55..aff29f75 100644
--- a/Core/Controllers/DialogueController.cs
+++ b/Core/Controllers/DialogueController.cs
@@ -1,14 +1,28 @@
using Core.Annotations;
+using Core.Helpers;
using Core.Models.Eft.Dialog;
using Core.Models.Eft.HttpResponse;
using Core.Models.Eft.Profile;
using Core.Models.Enums;
+using Core.Servers;
+using static System.Runtime.InteropServices.JavaScript.JSType;
namespace Core.Controllers;
[Injectable]
public class DialogueController
{
+ private readonly DialogueHelper _dialogueHelper;
+ private readonly SaveServer _saveServer;
+
+ public DialogueController(
+ DialogueHelper dialogueHelper,
+ SaveServer saveServer)
+ {
+ _dialogueHelper = dialogueHelper;
+ _saveServer = saveServer;
+ }
+
///
///
///
@@ -47,7 +61,13 @@ public class DialogueController
/// list of dialogs
public List GenerateDialogueList(string sessionId)
{
- throw new NotImplementedException();
+ var data = new List();
+ foreach (var dialogueId in _dialogueHelper.GetDialogsForProfile(sessionId))
+ {
+ data.Add(GetDialogueInfo(dialogueId.Key, sessionId));
+ }
+
+ return data;
}
///
@@ -60,7 +80,20 @@ public class DialogueController
string dialogueId,
string sessionId)
{
- throw new NotImplementedException();
+ var dialogs = _dialogueHelper.GetDialogsForProfile(sessionId);
+ var dialogue = dialogs.GetValueOrDefault(dialogueId);
+
+ var result = new DialogueInfo {
+ Id = dialogueId,
+ Type = dialogue.Type ?? MessageType.NPC_TRADER,
+ Message = _dialogueHelper.GetMessagePreview(dialogue),
+ New = dialogue.New,
+ AttachmentsNew = dialogue.AttachmentsNew,
+ Pinned = dialogue.Pinned,
+ Users = GetDialogueUsers(dialogue, dialogue.Type.Value, sessionId),
+ };
+
+ return result;
}
///
@@ -71,11 +104,36 @@ public class DialogueController
/// Player id
/// UserDialogInfo list
public List GetDialogueUsers(
- Dialogue dialogue,
+ Dialogue dialog,
MessageType messageType,
string sessionId)
{
- throw new NotImplementedException();
+ var profile = _saveServer.GetProfile(sessionId);
+
+ // User to user messages are special in that they need the player to exist in them, add if they don't
+ if (
+ messageType == MessageType.USER_MESSAGE &&
+ !dialog.Users.Any((userDialog) => userDialog.Id == profile.CharacterData.PmcData.SessionId))
+ {
+ // nullguard
+ dialog.Users ??= [];
+
+ dialog.Users.Add( new UserDialogInfo
+ {
+ Id = profile.CharacterData.PmcData.SessionId,
+ Aid = profile.CharacterData.PmcData.Aid,
+ Info = new UserDialogDetails
+ {
+ Level = profile.CharacterData.PmcData.Info.Level,
+ Nickname = profile.CharacterData.PmcData.Info.Nickname,
+ Side = profile.CharacterData.PmcData.Info.Side,
+ MemberCategory = profile.CharacterData.PmcData.Info.MemberCategory,
+ SelectedMemberCategory = profile.CharacterData.PmcData.Info.SelectedMemberCategory,
+ },
+ });
+ }
+
+ return dialog.Users;
}
///
diff --git a/Core/Models/Eft/Common/Tables/BotBase.cs b/Core/Models/Eft/Common/Tables/BotBase.cs
index 20c16a29..c283291f 100644
--- a/Core/Models/Eft/Common/Tables/BotBase.cs
+++ b/Core/Models/Eft/Common/Tables/BotBase.cs
@@ -14,7 +14,7 @@ public class BotBase
[JsonPropertyName("aid")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
- public double? Aid { get; set; }
+ public int? Aid { get; set; }
/** SPT property - use to store player id - TODO - move to AID ( account id as guid of choice) */
[JsonPropertyName("sessionId")]
@@ -153,7 +153,7 @@ public class Info
public bool? HasCoopExtension { get; set; }
public bool? HasPveGame { get; set; }
public string? Voice { get; set; }
- public double? Level { get; set; }
+ public int? Level { get; set; }
public double? Experience { get; set; }
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public long? RegistrationDate { get; set; }
diff --git a/Core/Models/Eft/Profile/UserDialogInfo.cs b/Core/Models/Eft/Profile/UserDialogInfo.cs
index 030cc515..21fa6bd6 100644
--- a/Core/Models/Eft/Profile/UserDialogInfo.cs
+++ b/Core/Models/Eft/Profile/UserDialogInfo.cs
@@ -1,10 +1,13 @@
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
using Core.Models.Enums;
namespace Core.Models.Eft.Profile;
public class UserDialogInfo
{
+ ///
+ /// _id
+ ///
[JsonPropertyName("_id")]
public string? Id { get; set; }
@@ -31,4 +34,4 @@ public class UserDialogDetails
[JsonPropertyName("SelectedMemberCategory")]
public MemberCategory? SelectedMemberCategory { get; set; }
-}
\ No newline at end of file
+}