BlueGit

ict rusty-teams

Files

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

models.rs

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