ruma_client_api/presence/
get_presence.rs1pub mod v3 {
6    use std::time::Duration;
11
12    use ruma_common::{
13        api::{request, response, Metadata},
14        metadata,
15        presence::PresenceState,
16        OwnedUserId,
17    };
18
19    const METADATA: Metadata = metadata! {
20        method: GET,
21        rate_limited: false,
22        authentication: AccessToken,
23        history: {
24            1.0 => "/_matrix/client/r0/presence/:user_id/status",
25            1.1 => "/_matrix/client/v3/presence/:user_id/status",
26        }
27    };
28
29    #[request(error = crate::Error)]
31    pub struct Request {
32        #[ruma_api(path)]
34        pub user_id: OwnedUserId,
35    }
36
37    #[response(error = crate::Error)]
39    pub struct Response {
40        #[serde(skip_serializing_if = "Option::is_none")]
42        pub status_msg: Option<String>,
43
44        #[serde(skip_serializing_if = "Option::is_none")]
46        pub currently_active: Option<bool>,
47
48        #[serde(
50            with = "ruma_common::serde::duration::opt_ms",
51            default,
52            skip_serializing_if = "Option::is_none"
53        )]
54        pub last_active_ago: Option<Duration>,
55
56        pub presence: PresenceState,
58    }
59
60    impl Request {
61        pub fn new(user_id: OwnedUserId) -> Self {
63            Self { user_id }
64        }
65    }
66
67    impl Response {
68        pub fn new(presence: PresenceState) -> Self {
70            Self { presence, status_msg: None, currently_active: None, last_active_ago: None }
71        }
72    }
73}