1use crate::prelude::*;
2
3use serde::{Deserialize, Serialize};
4use strum::Display;
5use strum_macros::EnumString;
6
7#[tsify_next::declare]
8pub type ChatId = uuid::Uuid;
9
10#[tsify_next::declare]
11pub type ChatMessageId = uuid::Uuid;
12
13#[derive(
14 Clone, Debug, Display, Deserialize, Serialize, EnumString, JsonSchema, Tsify, PartialEq, Eq,
15)]
16#[tsify(from_wasm_abi, into_wasm_abi)]
17pub enum ChatType {
18 Global,
19 Private,
20 GlobalSystem,
21 PersonalSystem,
22}
23
24#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema, Tsify)]
25#[tsify(from_wasm_abi, into_wasm_abi)]
26pub struct ChatSettings {
27 #[schemars(title = "Тип чата")]
28 pub chat_type: ChatType,
29
30 #[schemars(title = "Может ли пользователь писать в чат")]
31 pub user_allowed_to_write: bool,
32
33 #[schemars(title = "Получает ли пользователь уведомление при любом сообщении")]
34 pub get_notification_on_messages: bool,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, JsonSchema, Tsify)]
38#[tsify(from_wasm_abi, into_wasm_abi)]
39pub struct ChatMessage {
40 pub id: Option<ChatMessageId>,
41 pub sender_character_id: uuid::Uuid,
42 pub recipient_character_id: Option<uuid::Uuid>,
43 pub chat_id: Option<ChatId>,
44 pub chat_type: ChatType,
45 pub text: String,
46 pub created_at: chrono::DateTime<chrono::Utc>,
47}
48
49#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Tsify)]
50#[tsify(from_wasm_abi, into_wasm_abi)]
51pub struct Chat {
52 pub id: ChatId,
53 pub chat_type: ChatType,
54 pub messages: Vec<ChatMessage>,
55 pub last_read_message_id: Option<ChatMessageId>,
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Tsify)]
59#[tsify(from_wasm_abi, into_wasm_abi)]
60pub struct ReadMessage {
61 pub chat_id: ChatId,
62 pub message_id: ChatMessageId,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Tsify)]
66#[tsify(from_wasm_abi, into_wasm_abi)]
67pub struct ReportChatMessage {
68 pub message_id: ChatMessageId,
69}