zulip_api/message/unread_msgs/pm.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{field_access, impl_default, impl_display};
4
5/// Represents details of unread one-on-one direct messages with a specific user.
6///
7/// Note that it is possible for a message that the current user sent to the specified user to be marked as unread and thus appear here.
8///
9/// Modified from `openapi-generator-cli` output:
10///
11/// ```shell,no_build,no_run
12/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
13/// ```
14///
15/// ```text
16/// /*
17/// * Zulip REST API
18/// *
19/// * Powerful open source group chat
20/// *
21/// * The version of the OpenAPI document: 1.0.0
22/// *
23/// * Generated by: https://openapi-generator.tech
24/// */
25/// ```
26///
27/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
28///
29/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
30#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
31pub struct UnreadMsgsPm {
32 /// The user ID of the other participant in this one-on-one direct message conversation. Will be the current user's ID for messages that they sent in a one-on-one direct message conversation with themself. **Changes**: New in Zulip 5.0 (feature level 119), replacing the less clearly named `sender_id` field.
33 #[serde(skip_serializing_if = "Option::is_none")]
34 other_user_id: Option<u64>,
35 /// Old name for the `other_user_id` field. Clients should access this field in Zulip server versions that do not yet support `other_user_id`. **Changes**: Deprecated in Zulip 5.0 (feature level 119). We expect to provide a next version of the full `unread_msgs` API before removing this legacy name.
36 #[serde(skip_serializing_if = "Option::is_none")]
37 sender_id: Option<u64>,
38 /// The message IDs of the recent unread direct messages sent by either user in this one-on-one direct message conversation, sorted in ascending order.
39 #[serde(skip_serializing_if = "Option::is_none")]
40 unread_message_ids: Option<Vec<u64>>,
41}
42
43impl UnreadMsgsPm {
44 /// Creates a new [UnreadMsgsPm].
45 pub fn new() -> Self {
46 Self {
47 other_user_id: None,
48 sender_id: None,
49 unread_message_ids: None,
50 }
51 }
52}
53
54field_access! {
55 UnreadMsgsPm {
56 /// The user ID of the other participant in this one-on-one direct message conversation.
57 ///
58 /// Will be the current user's ID for messages that they sent in a one-on-one direct message conversation with themself.
59 ///
60 /// **Changes**: New in Zulip 5.0 (feature level 119), replacing the less clearly named `sender_id` field.
61 other_user_id: option { u64 },
62 /// Old name for the `other_user_id` field.
63 ///
64 /// Clients should access this field in Zulip server versions that do not yet support `other_user_id`.
65 ///
66 /// **Changes**: Deprecated in Zulip 5.0 (feature level 119). We expect to provide a next version of the full `unread_msgs` API before removing this legacy name.
67 sender_id: option { u64 },
68 }
69}
70
71field_access! {
72 UnreadMsgsPm {
73 /// The message IDs of the recent unread direct messages sent by either user in this one-on-one direct message conversation, sorted in ascending order.
74 unread_message_ids: option_cow_deref { [u64], Vec<u64> },
75 }
76}
77
78impl_default!(UnreadMsgsPm);
79impl_display!(UnreadMsgsPm);