BlueGit

ict rusty-teams

Files

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

models.rs

Initial commit
metis Daniel Däschle · pushed by metis · 7 weeks ago
06e0ae51 History
models.rs 3.8 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}
72
73#[derive(Debug, Clone, PartialEq)]
74pub struct SyncState {
75 pub newest_seen: Option<DateTime<Utc>>,
76 pub oldest_loaded: Option<DateTime<Utc>>,
77 pub has_more: bool,
78 pub older_cursor: Option<String>,
79 pub delta_link: Option<String>,
80}
81
82impl Default for SyncState {
83 fn default() -> Self {
84 SyncState {
85 newest_seen: None,
86 oldest_loaded: None,
87 has_more: true,
88 older_cursor: None,
89 delta_link: None,
90 }
91 }
92}
93
94#[derive(Debug, Clone, PartialEq)]
95pub struct SidebarTeam {
96 pub team: TeamRecord,
97 pub channels: Vec<ChannelRecord>,
98 pub hidden: bool,
99 pub hidden_channel_ids: Vec<String>,
100}
101
102#[derive(Debug, Clone, PartialEq, Eq)]
103pub struct ChannelLayoutRecord {
104 pub channel_id: String,
105 pub general: bool,
106 pub hidden: bool,
107}
108
109#[derive(Debug, Clone, PartialEq, Eq)]
110pub struct TeamLayoutRecord {
111 pub team_id: String,
112 pub hidden: bool,
113 pub channels: Vec<ChannelLayoutRecord>,
114}
115
116/// 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.
117#[derive(Debug, Clone, PartialEq, Default)]
118pub struct Sidebar {
119 pub chats: Vec<ChatRecord>,
120 pub teams: Vec<SidebarTeam>,
121}
122
123#[derive(Debug, Clone, Copy, PartialEq)]
124pub struct ChatPreview<'a> {
125 pub text: Option<&'a str>,
126 pub sender_id: Option<&'a str>,
127 pub sender_name: Option<&'a str>,
128 pub deleted: bool,
129}
130
131#[derive(Debug, Clone, PartialEq)]
132pub struct ImageRecord {
133 pub key: String,
134 pub bytes: Vec<u8>,
135 pub content_type: String,
136 pub fetched_at: DateTime<Utc>,
137}
138
139#[derive(Debug, Clone, PartialEq)]
140pub struct SearchHit {
141 pub conversation_id: String,
142 pub message_id: String,
143 pub sender_name: Option<String>,
144 pub created_at: DateTime<Utc>,
145 pub snippet: String,
146}
147
148#[derive(Debug, Clone, PartialEq, Eq)]
149pub struct ConversationHit {
150 pub conversation_id: String,
151 pub title: String,
152}