ruma_client_api/discovery/
discover_support.rs1use ruma_common::{
8 api::{auth_scheme::NoAuthentication, request, response},
9 metadata,
10 serde::StringEnum,
11 OwnedUserId,
12};
13use serde::{Deserialize, Serialize};
14
15use crate::PrivOwnedStr;
16
17metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: NoAuthentication,
21 path: "/.well-known/matrix/support",
22}
23
24#[request(error = crate::Error)]
26#[derive(Default)]
27pub struct Request {}
28
29#[response(error = crate::Error)]
31pub struct Response {
32 #[serde(default, skip_serializing_if = "Vec::is_empty")]
37 pub contacts: Vec<Contact>,
38
39 #[serde(skip_serializing_if = "Option::is_none")]
44 pub support_page: Option<String>,
45}
46
47impl Request {
48 pub fn new() -> Self {
50 Self {}
51 }
52}
53
54impl Response {
55 pub fn with_contacts(contacts: Vec<Contact>) -> Self {
57 Self { contacts, support_page: None }
58 }
59
60 pub fn with_support_page(support_page: String) -> Self {
62 Self { contacts: Vec::new(), support_page: Some(support_page) }
63 }
64}
65
66#[derive(Clone, Debug, Deserialize, Serialize)]
68#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
69pub struct Contact {
70 pub role: ContactRole,
72
73 #[serde(skip_serializing_if = "Option::is_none")]
77 pub email_address: Option<String>,
78
79 #[serde(skip_serializing_if = "Option::is_none")]
86 pub matrix_id: Option<OwnedUserId>,
87}
88
89impl Contact {
90 pub fn with_email_address(role: ContactRole, email_address: String) -> Self {
92 Self { role, email_address: Some(email_address), matrix_id: None }
93 }
94
95 pub fn with_matrix_id(role: ContactRole, matrix_id: OwnedUserId) -> Self {
97 Self { role, email_address: None, matrix_id: Some(matrix_id) }
98 }
99}
100
101#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
103#[derive(Clone, StringEnum)]
104#[ruma_enum(rename_all = "m.role.snake_case")]
105#[non_exhaustive]
106pub enum ContactRole {
107 Admin,
109
110 Security,
112
113 #[cfg(feature = "unstable-msc4121")]
117 #[ruma_enum(rename = "support.feline.msc4121.role.moderator", alias = "m.role.moderator")]
118 Moderator,
119
120 #[doc(hidden)]
121 _Custom(PrivOwnedStr),
122}