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