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        api::{request, response, Metadata},
12        metadata, OwnedEventId, OwnedRoomId,
13    };
14
15    const METADATA: Metadata = metadata! {
16        method: PUT,
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 `subscribe_thread` 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 subscribe to.
32        #[ruma_api(path)]
33        pub thread_root: OwnedEventId,
34
35        /// Whether the subscription was made automatically by a client, not by manual user choice,
36        /// and up to which event.
37        #[serde(skip_serializing_if = "Option::is_none")]
38        pub automatic: Option<OwnedEventId>,
39    }
40
41    /// Response type for the `subscribe_thread` endpoint.
42    #[response(error = crate::Error)]
43    pub struct Response {}
44
45    impl Request {
46        /// Creates a new `Request` for the given room and thread IDs.
47        ///
48        /// If `automatic` is set, it must be the ID of the last thread event causing an automatic
49        /// update, which is not necessarily the latest thread event. See the MSC for more details.
50        pub fn new(
51            room_id: OwnedRoomId,
52            thread_root: OwnedEventId,
53            automatic: Option<OwnedEventId>,
54        ) -> Self {
55            Self { room_id, thread_root, automatic }
56        }
57    }
58
59    impl Response {
60        /// Creates a new `Response`.
61        pub fn new() -> Self {
62            Self {}
63        }
64    }
65}