Skip to main content

librus_rs/structs/
messages.rs

1//! Message-related data types.
2
3use serde::Deserialize;
4
5/// Unread message counts across all folders.
6#[derive(Debug, Deserialize)]
7pub struct UnreadCounts {
8    /// Unread messages in inbox.
9    pub inbox: u32,
10    /// Unread notes.
11    pub notes: u32,
12    /// Unread alerts.
13    pub alerts: u32,
14    /// Unread substitution notifications.
15    pub substitutions: u32,
16    /// Unread absence notifications.
17    pub absences: u32,
18    /// Unread justification requests.
19    pub justifications: u32,
20    /// Items in trash.
21    pub trash: u32,
22    #[serde(rename = "archiveInbox")]
23    /// Archived inbox messages.
24    pub archive_inbox: u32,
25    #[serde(rename = "archiveNotes")]
26    /// Archived notes.
27    pub archive_notes: u32,
28    #[serde(rename = "archiveAlerts")]
29    /// Archived alerts.
30    pub archive_alerts: u32,
31    #[serde(rename = "archiveSubstitutions")]
32    /// Archived substitution notifications.
33    pub archive_substitutions: u32,
34    #[serde(rename = "archiveAbsences")]
35    /// Archived absence notifications.
36    pub archive_absences: u32,
37    #[serde(rename = "archiveJustifications")]
38    /// Archived justification requests.
39    pub archive_justifications: u32,
40    #[serde(rename = "archiveTrash")]
41    /// Archived trash items.
42    pub archive_trash: u32,
43}
44
45#[derive(Debug, Deserialize)]
46pub(crate) struct ResponseUnreadCounts {
47    pub data: UnreadCounts,
48}
49
50/// A message in the inbox (received message).
51#[derive(Debug, Deserialize)]
52#[serde(rename_all = "camelCase")]
53pub struct InboxMessage {
54    /// Unique message identifier.
55    pub message_id: String,
56    /// Sender's first name.
57    pub sender_first_name: String,
58    /// Sender's last name.
59    pub sender_last_name: String,
60    /// Sender's full display name.
61    pub sender_name: String,
62    /// Message subject/topic.
63    pub topic: String,
64    /// Message content (base64-encoded).
65    /// Use [`Client::decode_message_content`](crate::Client::decode_message_content) to decode.
66    pub content: String,
67    /// Date when the message was sent.
68    pub send_date: String,
69    /// Date when the message was read, if read.
70    pub read_date: Option<String>,
71    /// Whether the message has attachments.
72    pub is_any_file_attached: bool,
73    /// Message tags/labels.
74    pub tags: Vec<String>,
75    /// Message category.
76    pub category: Option<String>,
77}
78
79/// A message in the outbox (sent message).
80#[derive(Debug, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct OutboxMessage {
83    /// Unique message identifier.
84    pub message_id: String,
85    /// Receiver's first name.
86    pub receiver_first_name: String,
87    /// Receiver's last name.
88    pub receiver_last_name: String,
89    /// Receiver's full display name.
90    pub receiver_name: String,
91    /// Message subject/topic.
92    pub topic: String,
93    /// Message content (base64-encoded).
94    pub content: String,
95    /// Date when the message was sent.
96    pub send_date: String,
97    /// Whether the message has attachments.
98    pub is_any_file_attached: bool,
99    /// Message tags/labels.
100    pub tags: Vec<String>,
101    /// Message category.
102    pub category: Option<String>,
103}
104
105#[derive(Debug, Deserialize)]
106pub(crate) struct ResponseInboxMessages {
107    pub data: Vec<InboxMessage>,
108}
109
110#[derive(Debug, Deserialize)]
111pub(crate) struct ResponseOutboxMessages {
112    pub data: Vec<OutboxMessage>,
113}
114
115/// A file attachment in a message.
116#[derive(Debug, Deserialize)]
117#[serde(rename_all = "camelCase")]
118pub struct Attachment {
119    /// Unique attachment identifier.
120    pub id: String,
121    /// Original filename.
122    pub name: String,
123    /// File size in bytes.
124    pub size: Option<u64>,
125}
126
127/// Full message details including content and attachments.
128#[derive(Debug, Deserialize)]
129#[serde(rename_all = "camelCase")]
130pub struct MessageDetail {
131    /// Unique message identifier.
132    pub message_id: String,
133    /// Sender's user ID.
134    pub sender_id: Option<String>,
135    /// Sender's first name.
136    pub sender_first_name: String,
137    /// Sender's last name.
138    pub sender_last_name: String,
139    /// Sender's full display name.
140    pub sender_name: String,
141    /// Sender's group (e.g., teacher, parent).
142    pub sender_group: Option<String>,
143    /// Message subject/topic.
144    pub topic: String,
145    /// Full message content (base64-encoded).
146    /// Use [`Client::decode_message_content`](crate::Client::decode_message_content) to decode.
147    #[serde(rename = "Message")]
148    pub message: String,
149    /// Date when the message was sent.
150    pub send_date: String,
151    /// Date when the message was read, if read.
152    pub read_date: Option<String>,
153    /// List of file attachments.
154    pub attachments: Vec<Attachment>,
155    /// Number of receivers (for group messages).
156    pub receivers_count: Option<u32>,
157    /// Whether replies are disabled (1 = no reply allowed).
158    pub no_reply: Option<u8>,
159    /// Whether the message is archived (1 = archived).
160    pub archive: Option<u8>,
161}
162
163#[derive(Debug, Deserialize)]
164pub(crate) struct ResponseMessageDetail {
165    pub data: MessageDetail,
166}