| 1 | use chrono::{DateTime, Utc}; |
| 2 | |
| 3 | #[derive(Debug, Clone, PartialEq, Default)] |
| 4 | pub struct MemberRecord { |
| 5 | pub user_id: Option<String>, |
| 6 | pub display_name: String, |
| 7 | } |
| 8 | |
| 9 | #[derive(Debug, Clone, PartialEq, Default)] |
| 10 | pub 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)] |
| 28 | pub 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)] |
| 36 | pub 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)] |
| 44 | pub struct TeamRecord { |
| 45 | pub id: String, |
| 46 | pub name: String, |
| 47 | } |
| 48 | |
| 49 | #[derive(Debug, Clone, PartialEq)] |
| 50 | pub 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)] |
| 60 | pub 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 | } |
| 75 | |
| 76 | #[derive(Debug, Clone, PartialEq)] |
| 77 | pub struct SyncState { |
| 78 | pub newest_seen: Option<DateTime<Utc>>, |
| 79 | pub oldest_loaded: Option<DateTime<Utc>>, |
| 80 | pub has_more: bool, |
| 81 | pub older_cursor: Option<String>, |
| 82 | pub delta_link: Option<String>, |
| 83 | } |
| 84 | |
| 85 | impl Default for SyncState { |
| 86 | fn default() -> Self { |
| 87 | SyncState { |
| 88 | newest_seen: None, |
| 89 | oldest_loaded: None, |
| 90 | has_more: true, |
| 91 | older_cursor: None, |
| 92 | delta_link: None, |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | #[derive(Debug, Clone, PartialEq)] |
| 98 | pub struct SidebarTeam { |
| 99 | pub team: TeamRecord, |
| 100 | pub channels: Vec<ChannelRecord>, |
| 101 | pub hidden: bool, |
| 102 | pub hidden_channel_ids: Vec<String>, |
| 103 | } |
| 104 | |
| 105 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 106 | pub struct ChannelLayoutRecord { |
| 107 | pub channel_id: String, |
| 108 | pub general: bool, |
| 109 | pub hidden: bool, |
| 110 | } |
| 111 | |
| 112 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 113 | pub struct TeamLayoutRecord { |
| 114 | pub team_id: String, |
| 115 | pub hidden: bool, |
| 116 | pub channels: Vec<ChannelLayoutRecord>, |
| 117 | } |
| 118 | |
| 119 | /// 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. |
| 120 | #[derive(Debug, Clone, PartialEq, Default)] |
| 121 | pub struct Sidebar { |
| 122 | pub chats: Vec<ChatRecord>, |
| 123 | pub teams: Vec<SidebarTeam>, |
| 124 | } |
| 125 | |
| 126 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 127 | pub struct ChatPreview<'a> { |
| 128 | pub text: Option<&'a str>, |
| 129 | pub sender_id: Option<&'a str>, |
| 130 | pub sender_name: Option<&'a str>, |
| 131 | pub deleted: bool, |
| 132 | } |
| 133 | |
| 134 | #[derive(Debug, Clone, PartialEq)] |
| 135 | pub struct ImageRecord { |
| 136 | pub key: String, |
| 137 | pub bytes: Vec<u8>, |
| 138 | pub content_type: String, |
| 139 | pub fetched_at: DateTime<Utc>, |
| 140 | } |
| 141 | |
| 142 | #[derive(Debug, Clone, PartialEq)] |
| 143 | pub struct SearchHit { |
| 144 | pub conversation_id: String, |
| 145 | pub message_id: String, |
| 146 | pub sender_name: Option<String>, |
| 147 | pub created_at: DateTime<Utc>, |
| 148 | pub snippet: String, |
| 149 | } |
| 150 | |
| 151 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 152 | pub struct ConversationHit { |
| 153 | pub conversation_id: String, |
| 154 | pub title: String, |
| 155 | } |
| 156 | |
| 157 | #[derive(Debug, Clone, PartialEq)] |
| 158 | pub struct ActivityRecord { |
| 159 | pub id: i64, |
| 160 | pub conversation_id: String, |
| 161 | pub kind: String, |
| 162 | pub message_id: String, |
| 163 | pub actors_json: String, |
| 164 | pub preview: String, |
| 165 | pub glyphs: String, |
| 166 | pub count: u32, |
| 167 | pub updated_at: DateTime<Utc>, |
| 168 | pub read: bool, |
| 169 | } |