BlueGit

ict rusty-teams

Files

rusty-teams / crates / store / src / models.rs

models.rs

models.rs 4.1 KiB Download Raw
1use chrono::{DateTime, Utc};
2
3#[derive(Debug, Clone, PartialEq, Default)]
4pub struct MemberRecord {
5 pub user_id: Option<String>,
6 pub display_name: String,
7}
8
9#[derive(Debug, Clone, PartialEq, Default)]
10pub struct ChatRecord {
11 pub id: String,
12 pub kind: String,
13 pub title: String,
14 pub member_summary: String,
15 pub last_message_at: Option<DateTime<Utc>>,
16 pub last_read_at: Option<DateTime<Utc>>,
17 pub unread: bool,
18 pub members: Vec<MemberRecord>,
19 pub last_message_preview: Option<String>,
20 pub last_message_sender_id: Option<String>,
21 pub last_message_sender_name: Option<String>,
22 pub last_message_deleted: bool,
23}
24
25#[derive(Debug, Clone, PartialEq)]
26pub struct AvatarRecord {
27 pub user_id: String,
28 pub bytes: Option<Vec<u8>>,
29 pub content_type: String,
30 pub fetched_at: DateTime<Utc>,
31}
32
33#[derive(Debug, Clone, PartialEq)]
34pub struct FolderRecord {
35 pub id: String,
36 pub name: String,
37 pub kind: String,
38 pub conversation_ids: Vec<String>,
39}
40
41#[derive(Debug, Clone, PartialEq)]
42pub struct TeamRecord {
43 pub id: String,
44 pub name: String,
45}
46
47#[derive(Debug, Clone, PartialEq)]
48pub struct ChannelRecord {
49 pub id: String,
50 pub team_id: String,
51 pub name: String,
52 pub membership_type: Option<String>,
53 pub last_message_at: Option<DateTime<Utc>>,
54 pub unread: bool,
55}
56
57#[derive(Debug, Clone, PartialEq, Default)]
58pub struct MessageRecord {
59 pub conversation_id: String,
60 pub message_id: String,
61 pub reply_to_id: Option<String>,
62 pub sender_id: Option<String>,
63 pub sender_name: Option<String>,
64 pub created_at: DateTime<Utc>,
65 pub edited_at: Option<DateTime<Utc>>,
66 pub deleted: bool,
67 pub body_html: String,
68 pub attachments_json: String,
69 pub reactions_json: String,
70 pub mentions_json: String,
71 pub sender_application_id: Option<String>,
72}
73
74#[derive(Debug, Clone, PartialEq)]
75pub struct SyncState {
76 pub newest_seen: Option<DateTime<Utc>>,
77 pub oldest_loaded: Option<DateTime<Utc>>,
78 pub has_more: bool,
79 pub older_cursor: Option<String>,
80 pub delta_link: Option<String>,
81}
82
83impl Default for SyncState {
84 fn default() -> Self {
85 SyncState {
86 newest_seen: None,
87 oldest_loaded: None,
88 has_more: true,
89 older_cursor: None,
90 delta_link: None,
91 }
92 }
93}
94
95#[derive(Debug, Clone, PartialEq)]
96pub struct SidebarTeam {
97 pub team: TeamRecord,
98 pub channels: Vec<ChannelRecord>,
99 pub hidden: bool,
100 pub hidden_channel_ids: Vec<String>,
101}
102
103#[derive(Debug, Clone, PartialEq, Eq)]
104pub struct ChannelLayoutRecord {
105 pub channel_id: String,
106 pub general: bool,
107 pub hidden: bool,
108}
109
110#[derive(Debug, Clone, PartialEq, Eq)]
111pub struct TeamLayoutRecord {
112 pub team_id: String,
113 pub hidden: bool,
114 pub channels: Vec<ChannelLayoutRecord>,
115}
116
117/// Everything the sidebar renders: chats by last message (newest first), teams in the user's Teams order (alphabetical without one), General first, then channels by name.
118#[derive(Debug, Clone, PartialEq, Default)]
119pub struct Sidebar {
120 pub chats: Vec<ChatRecord>,
121 pub teams: Vec<SidebarTeam>,
122}
123
124#[derive(Debug, Clone, Copy, PartialEq)]
125pub struct ChatPreview<'a> {
126 pub text: Option<&'a str>,
127 pub sender_id: Option<&'a str>,
128 pub sender_name: Option<&'a str>,
129 pub deleted: bool,
130}
131
132#[derive(Debug, Clone, PartialEq)]
133pub struct ImageRecord {
134 pub key: String,
135 pub bytes: Vec<u8>,
136 pub content_type: String,
137 pub fetched_at: DateTime<Utc>,
138}
139
140#[derive(Debug, Clone, PartialEq)]
141pub struct SearchHit {
142 pub conversation_id: String,
143 pub message_id: String,
144 pub sender_name: Option<String>,
145 pub created_at: DateTime<Utc>,
146 pub snippet: String,
147}
148
149#[derive(Debug, Clone, PartialEq, Eq)]
150pub struct ConversationHit {
151 pub conversation_id: String,
152 pub title: String,
153}
154
155#[derive(Debug, Clone, PartialEq)]
156pub struct ActivityRecord {
157 pub id: i64,
158 pub conversation_id: String,
159 pub kind: String,
160 pub message_id: String,
161 pub actors_json: String,
162 pub preview: String,
163 pub glyphs: String,
164 pub count: u32,
165 pub updated_at: DateTime<Utc>,
166 pub read: bool,
167}