From f69862fbccc372c1dbda999d3c76afe4204b033a Mon Sep 17 00:00:00 2001 From: sdcb Date: Thu, 2 Jan 2025 12:42:52 +0800 Subject: [PATCH] add created at in chat response --- src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs | 3 +++ src/BE/Controllers/Chats/UserChats/UserChatsController.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs b/src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs index 14460528..07b68bad 100644 --- a/src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs +++ b/src/BE/Controllers/Chats/UserChats/Dtos/ChatsResponse.cs @@ -19,6 +19,9 @@ public record ChatsResponse [JsonPropertyName("leafMessageId")] public required string? LeafMessageId { get; init; } + + [JsonPropertyName("createdAt")] + public required DateTime CreatedAt { get; init; } } public record ChatSpanDto diff --git a/src/BE/Controllers/Chats/UserChats/UserChatsController.cs b/src/BE/Controllers/Chats/UserChats/UserChatsController.cs index 80ab40aa..9e2fb6cc 100644 --- a/src/BE/Controllers/Chats/UserChats/UserChatsController.cs +++ b/src/BE/Controllers/Chats/UserChats/UserChatsController.cs @@ -35,6 +35,7 @@ public async Task> GetOneChat(string encryptedChatId EnableSearch = s.EnableSearch, }).ToArray(), LeafMessageId = x.LeafMessageId != null ? idEncryption.EncryptMessageId(x.LeafMessageId.Value) : null, + CreatedAt = x.CreatedAt, }) .FirstOrDefaultAsync(cancellationToken); @@ -73,6 +74,7 @@ public async Task>> GetChats([FromQuery] EnableSearch = s.EnableSearch, }).ToArray(), LeafMessageId = x.LeafMessageId != null ? idEncryption.EncryptMessageId(x.LeafMessageId.Value) : null, + CreatedAt = x.CreatedAt, }), request, cancellationToken); @@ -145,6 +147,7 @@ public async Task> CreateChat([FromBody] CreateChatR EnableSearch = s.EnableSearch, }).ToArray(), LeafMessageId = chat.LeafMessageId != null ? idEncryption.EncryptMessageId(chat.LeafMessageId.Value) : null, + CreatedAt = chat.CreatedAt, }); }