Skip to main content

matrix_bridge_telegram/db/
models.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct UserMapping {
6    pub id: i64,
7    pub matrix_user_id: String,
8    pub telegram_user_id: i64,
9    pub telegram_username: Option<String>,
10    pub telegram_first_name: Option<String>,
11    pub telegram_last_name: Option<String>,
12    pub telegram_phone: Option<String>,
13    pub telegram_avatar: Option<String>,
14    pub created_at: DateTime<Utc>,
15    pub updated_at: DateTime<Utc>,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19pub struct PortalInfo {
20    pub id: i64,
21    pub matrix_room_id: String,
22    pub telegram_chat_id: i64,
23    pub telegram_chat_type: String,
24    pub telegram_chat_title: Option<String>,
25    pub telegram_chat_username: Option<String>,
26    pub created_at: DateTime<Utc>,
27    pub updated_at: DateTime<Utc>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct MessageMapping {
32    pub id: i64,
33    pub telegram_message_id: i64,
34    pub telegram_chat_id: i64,
35    pub matrix_room_id: String,
36    pub matrix_event_id: String,
37    pub created_at: DateTime<Utc>,
38    pub updated_at: DateTime<Utc>,
39}
40
41#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct ReactionMapping {
43    pub id: i64,
44    pub telegram_message_id: i64,
45    pub telegram_chat_id: i64,
46    pub telegram_user_id: i64,
47    pub reaction_emoji: String,
48    pub matrix_event_id: String,
49    pub matrix_room_id: String,
50    pub created_at: DateTime<Utc>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize)]
54pub struct TelegramFileInfo {
55    pub id: i64,
56    pub telegram_file_id: String,
57    pub telegram_file_unique_id: String,
58    pub mxc_url: String,
59    pub mime_type: Option<String>,
60    pub file_name: Option<String>,
61    pub file_size: Option<i64>,
62    pub created_at: DateTime<Utc>,
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
66pub struct TelegramUserInfo {
67    pub id: i64,
68    pub telegram_user_id: i64,
69    pub matrix_mxid: String,
70    pub displayname: Option<String>,
71    pub avatar_mxc: Option<String>,
72    pub created_at: DateTime<Utc>,
73    pub updated_at: DateTime<Utc>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
77pub struct ProcessedEvent {
78    pub id: i64,
79    pub event_id: String,
80    pub event_type: String,
81    pub source: String,
82    pub processed_at: DateTime<Utc>,
83}