botx_api/api/v3/chats/info/
models.rs

1use chrono::{DateTime, Utc};
2use serde::{Serialize, Deserialize};
3use uuid::Uuid;
4
5use crate::{bot::models::{ChatType, UserKind}, api::models::{ChatNotFound, ErrorFromMessagingService}};
6
7/// Ответ eXpress на запрос информации о чате
8#[derive(Debug, Serialize, Deserialize, Clone)]
9pub struct ChatInfoResponse {
10    /// Результат запроса
11    pub result: ChatInfoResult,
12}
13
14/// Результат обработки запроса информации о чате
15#[derive(Debug, Serialize, Deserialize, Clone)]
16pub struct ChatInfoResult {
17    pub chat_type: ChatType,
18    pub creator: Uuid,
19    pub description: Option<String>,
20    pub group_chat_id: Uuid,
21    pub inserted_at: DateTime<Utc>,
22    pub members: Vec<ChatMember>,
23    pub name: String,
24    pub shared_history: bool,
25}
26
27/// Информация об участнике чата
28#[derive(Debug, Serialize, Deserialize, Clone)]
29pub struct ChatMember {
30    /// Признак администратора
31    pub admin: bool,
32
33    /// id сервера на котором авторизован пользователь?
34    pub server_id: Uuid,
35
36    /// id пользователя в системе eXpress
37    pub user_huid: Uuid,
38
39    /// Тип пользователя
40    pub user_kind: UserKind,
41}
42
43/// Ошибки при запросе информации о чате
44#[derive(Debug, Serialize, Deserialize, Clone)]
45#[serde(tag = "reason")]
46pub enum ChatInfoError {
47    /// Чат не найден
48    #[serde(rename(serialize = "chat_not_found", deserialize = "chat_not_found"))]
49    ChatNotFound(ChatNotFound),
50
51    /// Ошибка от Messaging сервиса
52    #[serde(rename(serialize = "error_from_messaging_service", deserialize = "error_from_messaging_service"))]
53    ErrorFromMessagingService(ErrorFromMessagingService),
54
55    // TODO: добавить десериализацию в HashMap<string, string> когда завезут реализацию
56    /// Неопределенная ошибка, смотрите логи
57    #[serde(other)]
58    Other,
59}