ruma_client_api/threads/
get_thread_subscription.rs

1//! `GET /_matrix/client/*/rooms/{roomId}/thread/{eventId}/subscription`
2//!
3//! Gets the subscription state of the current user to a thread in a room.
4
5pub mod unstable {
6    //! `/unstable/` ([spec])
7    //!
8    //! [spec]: https://github.com/matrix-org/matrix-spec-proposals/pull/4306
9
10    use ruma_common::{
11        api::{request, response, Metadata},
12        metadata, OwnedEventId, OwnedRoomId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: GET,
17        rate_limited: true,
18        authentication: AccessToken,
19        history: {
20            unstable("org.matrix.msc4306") => "/_matrix/client/unstable/io.element.msc4306/rooms/{room_id}/thread/{thread_root}/subscription",
21        }
22    };
23
24    /// Request type for the `get_thread_subscription` endpoint.
25    #[request(error = crate::Error)]
26    pub struct Request {
27        /// The room ID where the thread is located.
28        #[ruma_api(path)]
29        pub room_id: OwnedRoomId,
30
31        /// The event ID of the thread root to get the status for.
32        #[ruma_api(path)]
33        pub thread_root: OwnedEventId,
34    }
35
36    /// Response type for the `get_thread_subscription` endpoint.
37    #[response(error = crate::Error)]
38    pub struct Response {
39        /// Whether the subscription was made automatically by a client, not by manual user choice.
40        pub automatic: bool,
41    }
42
43    impl Request {
44        /// Creates a new `Request` for the given room and thread IDs.
45        pub fn new(room_id: OwnedRoomId, thread_root: OwnedEventId) -> Self {
46            Self { room_id, thread_root }
47        }
48    }
49
50    impl Response {
51        /// Creates a new `Response`.
52        pub fn new(automatic: bool) -> Self {
53            Self { automatic }
54        }
55    }
56}