synapse_admin_api/experimental_features/list_features/
v1.rs1use ruma::{
4 api::{request, response, Metadata},
5 metadata, OwnedUserId,
6};
7use serde::{Deserialize, Serialize};
8
9use crate::experimental_features::enable_features::v1::ExperimentalFeatures;
10
11const METADATA: Metadata = metadata! {
12 method: GET,
13 rate_limited: false,
14 authentication: AccessToken,
15 history: {
16 unstable => "/_synapse/admin/v1/experimental_features/{user_id}",
17 }
18};
19
20#[request]
21#[derive(Serialize, Deserialize, PartialEq)]
22pub struct Request {
23 #[ruma_api(path)]
25 pub user_id: OwnedUserId,
26}
27
28#[response]
29#[derive(Serialize, Deserialize, PartialEq)]
30pub struct Response {
31 pub features: ExperimentalFeatures,
33}
34
35impl Request {
36 pub fn new(user_id: OwnedUserId) -> Self {
38 Self { user_id }
39 }
40}
41
42impl Response {
43 pub fn new(features: ExperimentalFeatures) -> Self {
45 Self { features }
46 }
47}
48
49#[test]
50fn test_list_features() {
51 let response = Response {
52 features: ExperimentalFeatures {
53 msc3026: Option::from(false),
54 msc3881: None,
55 msc3967: None,
56 },
57 };
58
59 let json_str = "{\"features\":{\"msc3026\":false}}";
60 let deserialized: Response = serde_json::from_str(json_str).expect("Failed to deserialize");
62 assert_eq!(deserialized, response);
63
64 let serialized = serde_json::to_string(&response).expect("Failed to serialize");
66 assert_eq!(serialized, json_str);
67}