ruma_client_api/threads/
subscribe_thread.rs

1//! `PUT /_matrix/client/*/rooms/{roomId}/thread/{eventId}/subscription`
2//!
3//! Updates 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        OwnedEventId, OwnedRoomId,
12        api::{auth_scheme::AccessToken, request, response},
13        metadata,
14    };
15
16    metadata! {
17        method: PUT,
18        rate_limited: true,
19        authentication: AccessToken,
20        history: {
21            unstable("org.matrix.msc4306") => "/_matrix/client/unstable/io.element.msc4306/rooms/{room_id}/thread/{thread_root}/subscription",
22        }
23    }
24
25    /// Request type for the `subscribe_thread` endpoint.
26    #[request(error = crate::Error)]
27    pub struct Request {
28        /// The room ID where the thread is located.
29        #[ruma_api(path)]
30        pub room_id: OwnedRoomId,
31
32        /// The event ID of the thread root to subscribe to.
33        #[ruma_api(path)]
34        pub thread_root: OwnedEventId,
35
36        /// Whether the subscription was made automatically by a client, not by manual user choice,
37        /// and up to which event.
38        #[serde(skip_serializing_if = "Option::is_none")]
39        pub automatic: Option<OwnedEventId>,
40    }
41
42    /// Response type for the `subscribe_thread` endpoint.
43    #[response(error = crate::Error)]
44    pub struct Response {}
45
46    impl Request {
47        /// Creates a new `Request` for the given room and thread IDs.
48        ///
49        /// If `automatic` is set, it must be the ID of the last thread event causing an automatic
50        /// update, which is not necessarily the latest thread event. See the MSC for more details.
51        pub fn new(
52            room_id: OwnedRoomId,
53            thread_root: OwnedEventId,
54            automatic: Option<OwnedEventId>,
55        ) -> Self {
56            Self { room_id, thread_root, automatic }
57        }
58    }
59
60    impl Response {
61        /// Creates a new `Response`.
62        pub fn new() -> Self {
63            Self {}
64        }
65    }
66}