| 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 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)] |
| 26 | pub 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)] |
| 34 | pub 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)] |
| 42 | pub struct TeamRecord { |
| 43 | pub id: String, |
| 44 | pub name: String, |
| 45 | } |
| 46 | |
| 47 | #[derive(Debug, Clone, PartialEq)] |
| 48 | pub 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)] |
| 58 | pub 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)] |
| 74 | pub 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 | |
| 82 | impl 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)] |
| 95 | pub 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)] |
| 103 | pub struct ChannelLayoutRecord { |
| 104 | pub channel_id: String, |
| 105 | pub general: bool, |
| 106 | pub hidden: bool, |
| 107 | } |
| 108 | |
| 109 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 110 | pub 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)] |
| 118 | pub struct Sidebar { |
| 119 | pub chats: Vec<ChatRecord>, |
| 120 | pub teams: Vec<SidebarTeam>, |
| 121 | } |
| 122 | |
| 123 | #[derive(Debug, Clone, Copy, PartialEq)] |
| 124 | pub 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)] |
| 132 | pub 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)] |
| 140 | pub 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)] |
| 149 | pub struct ConversationHit { |
| 150 | pub conversation_id: String, |
| 151 | pub title: String, |
| 152 | } |