From 8ed76bc40fa0cfffc185bdb387394886f1efb7f3 Mon Sep 17 00:00:00 2001 From: KaenoDev <193943350+KaenoDev@users.noreply.github.com> Date: Mon, 20 Jan 2025 00:56:00 +0000 Subject: [PATCH] Add missing properties in itemeventrouter. implement GetAllAttachments. Requires item move handling to be finished --- .../Core/Controllers/DialogueController.cs | 25 +++++++++++++++++-- .../Eft/ItemEvent/ItemEventRouterRequest.cs | 15 +++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Libraries/Core/Controllers/DialogueController.cs b/Libraries/Core/Controllers/DialogueController.cs index 5dd5f133..401a114d 100644 --- a/Libraries/Core/Controllers/DialogueController.cs +++ b/Libraries/Core/Controllers/DialogueController.cs @@ -398,7 +398,28 @@ public class DialogueController( /// GetAllAttachmentsResponse or null if dialogue doesnt exist public GetAllAttachmentsResponse GetAllAttachments(string dialogueId, string sessionId) { - throw new NotImplementedException(); + var dialogs = _dialogueHelper.GetDialogsForProfile(sessionId); + var dialog = dialogs.TryGetValue(dialogueId, out var dialogInfo); + if (!dialog) + { + _logger.Error( + _localisationService.GetText("dialogue-unable_to_find_in_profile")); + + return null; + } + + // Removes corner 'new messages' tag + dialogInfo.AttachmentsNew = 0; + + var activeMessages = GetActiveMessagesFromDialog(sessionId, dialogueId); + var messagesWithAttachments = GetMessageWithAttachments(activeMessages); + + return new GetAllAttachmentsResponse { + Messages = messagesWithAttachments, + Profiles = [], + HasMessagesWithRewards = MessagesHaveUncollectedRewards(messagesWithAttachments) + + }; } /// @@ -435,7 +456,7 @@ public class DialogueController( /// messages with items to collect private List GetMessageWithAttachments(List messages) { - throw new NotImplementedException(); + return messages.Where(message => (message.Items?.Data?.Count ?? 0) > 0).ToList(); } /// diff --git a/Libraries/Core/Models/Eft/ItemEvent/ItemEventRouterRequest.cs b/Libraries/Core/Models/Eft/ItemEvent/ItemEventRouterRequest.cs index b13114cf..f6519005 100644 --- a/Libraries/Core/Models/Eft/ItemEvent/ItemEventRouterRequest.cs +++ b/Libraries/Core/Models/Eft/ItemEvent/ItemEventRouterRequest.cs @@ -25,6 +25,21 @@ public record Daum [JsonPropertyName("to")] public To? To { get; set; } + + [JsonPropertyName("with")] + public string? With { get; set; } + + [JsonPropertyName("fromOwner")] + public FromOwner? FromOwner { get; set; } +} + +public record FromOwner +{ + [JsonPropertyName("id")] + public string? Id { get; set; } + + [JsonPropertyName("type")] + public string? Type { get; set; } } public record To