BotSharp/src/Infrastructure/BotSharp.OpenAPI/ViewModels/Conversations/ConversationViewModel.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2023-11-15 13:33:46 +00:00
using System.Text.Json.Serialization;
2023-08-19 00:15:02 +00:00
namespace BotSharp.OpenAPI.ViewModels.Conversations;
public class ConversationViewModel
{
public string Id { get; set; }
2023-11-15 13:33:46 +00:00
[JsonPropertyName("agent_id")]
2023-08-19 00:15:02 +00:00
public string AgentId { get; set; }
2023-11-15 13:33:46 +00:00
2023-08-19 00:15:02 +00:00
public string Title { get; set; } = string.Empty;
2023-11-15 13:33:46 +00:00
2023-11-14 01:25:25 +00:00
public UserViewModel User { get; set; } = new UserViewModel();
2023-11-15 13:33:46 +00:00
[JsonPropertyName("unread_msg_count")]
2023-11-14 04:56:06 +00:00
public int UnreadMsgCount { get; set; }
2023-11-15 13:33:46 +00:00
public string Event { get; set; }
public string Channel { get; set; } = ConversationChannel.OpenAPI;
2023-11-15 13:33:46 +00:00
public string Status { get; set; }
2024-01-02 17:40:08 +00:00
public Dictionary<string, string> States { get; set; }
2023-11-15 13:33:46 +00:00
[JsonPropertyName("updated_time")]
2023-08-19 00:15:02 +00:00
public DateTime UpdatedTime { get; set; } = DateTime.UtcNow;
2023-11-15 13:33:46 +00:00
[JsonPropertyName("created_time")]
2023-08-19 00:15:02 +00:00
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
public static ConversationViewModel FromSession(Conversation sess)
{
return new ConversationViewModel
{
Id = sess.Id,
2023-11-14 01:25:25 +00:00
User = new UserViewModel
{
Id = sess.UserId
},
2023-08-19 00:15:02 +00:00
AgentId = sess.AgentId,
Title = sess.Title,
Channel = sess.Channel,
2023-11-15 13:33:46 +00:00
Status = sess.Status,
2023-08-19 00:15:02 +00:00
CreatedTime = sess.CreatedTime,
UpdatedTime = sess.UpdatedTime
};
}
}