ruma_client_api/discovery/
discover_support.rs1use ruma_common::{
8 api::{request, response, Metadata},
9 metadata,
10 serde::StringEnum,
11 OwnedUserId,
12};
13use serde::{Deserialize, Serialize};
14
15use crate::PrivOwnedStr;
16
17const METADATA: Metadata = metadata! {
18 method: GET,
19 rate_limited: false,
20 authentication: None,
21 history: {
22 1.10 => "/.well-known/matrix/support",
23 }
24};
25
26#[request(error = crate::Error)]
28#[derive(Default)]
29pub struct Request {}
30
31#[response(error = crate::Error)]
33pub struct Response {
34 #[serde(default, skip_serializing_if = "Vec::is_empty")]
39 pub contacts: Vec<Contact>,
40
41 #[serde(skip_serializing_if = "Option::is_none")]
46 pub support_page: Option<String>,
47}
48
49impl Request {
50 pub fn new() -> Self {
52 Self {}
53 }
54}
55
56impl Response {
57 pub fn with_contacts(contacts: Vec<Contact>) -> Self {
59 Self { contacts, support_page: None }
60 }
61
62 pub fn with_support_page(support_page: String) -> Self {
64 Self { contacts: Vec::new(), support_page: Some(support_page) }
65 }
66}
67
68#[derive(Clone, Debug, Deserialize, Serialize)]
70#[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
71pub struct Contact {
72 pub role: ContactRole,
74
75 #[serde(skip_serializing_if = "Option::is_none")]
79 pub email_address: Option<String>,
80
81 #[serde(skip_serializing_if = "Option::is_none")]
88 pub matrix_id: Option<OwnedUserId>,
89}
90
91impl Contact {
92 pub fn with_email_address(role: ContactRole, email_address: String) -> Self {
94 Self { role, email_address: Some(email_address), matrix_id: None }
95 }
96
97 pub fn with_matrix_id(role: ContactRole, matrix_id: OwnedUserId) -> Self {
99 Self { role, email_address: None, matrix_id: Some(matrix_id) }
100 }
101}
102
103#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
105#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
106#[ruma_enum(rename_all = "m.role.snake_case")]
107#[non_exhaustive]
108pub enum ContactRole {
109 Admin,
111
112 Security,
114
115 #[cfg(feature = "unstable-msc4121")]
119 #[ruma_enum(rename = "support.feline.msc4121.role.moderator", alias = "m.role.moderator")]
120 Moderator,
121
122 #[doc(hidden)]
123 _Custom(PrivOwnedStr),
124}