palpo_core/client/room/alias.rs
1/// `GET /_matrix/client/*/rooms/{room_id}/aliases`
2///
3/// Get a list of aliases maintained by the local server for the given room.
4/// `/v3/` ([spec])
5///
6/// [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3roomsroomidaliases
7use salvo::prelude::*;
8use serde::{Deserialize, Serialize};
9
10use crate::{OwnedRoomAliasId, OwnedRoomId, OwnedServerName};
11
12// const METADATA: Metadata = metadata! {
13// method: GET,
14// rate_limited: true,
15// authentication: AccessToken,
16// history: {
17// unstable => "/_matrix/client/unstable/org.matrix.msc2432/rooms/:room_id/aliases",
18// 1.0 => "/_matrix/client/r0/rooms/:room_id/aliases",
19// 1.1 => "/_matrix/client/v3/rooms/:room_id/aliases",
20// }
21// };
22
23// /// Request type for the `aliases` endpoint.
24
25// pub struct Requesxt {
26// /// The room ID to get aliases of.
27// #[salvo(parameter(parameter_in = Path))]
28// pub room_id: OwnedRoomId,
29// }
30
31/// Response type for the `aliases` endpoint.
32#[derive(ToSchema, Serialize, Debug)]
33pub struct AliasesResBody {
34 /// The server's local aliases on the room.
35 pub aliases: Vec<OwnedRoomAliasId>,
36}
37impl AliasesResBody {
38 /// Creates a new `Response` with the given aliases.
39 pub fn new(aliases: Vec<OwnedRoomAliasId>) -> Self {
40 Self { aliases }
41 }
42}
43
44/// Endpoints for room aliases.
45/// `GET /_matrix/client/*/directory/room/{roomAlias}`
46///
47/// Resolve a room alias to a room ID.
48/// `/v3/` ([spec])
49///
50/// [spec]: https://spec.matrix.org/latest/client-server-api/#get_matrixclientv3directoryroomroomalias
51
52// const METADATA: Metadata = metadata! {
53// method: GET,
54// rate_limited: false,
55// authentication: None,
56// history: {
57// 1.0 => "/_matrix/client/r0/directory/room/:room_alias",
58// 1.1 => "/_matrix/client/v3/directory/room/:room_alias",
59// }
60// };
61
62// /// Request type for the `get_alias` endpoint.
63
64// pub struct Requesxt {
65// /// The room alias.
66// #[salvo(parameter(parameter_in = Path))]
67// pub room_alias: OwnedRoomAliasId,
68// }
69
70/// Response type for the `get_alias` endpoint.
71
72#[derive(ToSchema, Serialize, Deserialize, Debug)]
73pub struct AliasResBody {
74 /// The room ID for this room alias.
75 pub room_id: OwnedRoomId,
76
77 /// A list of servers that are aware of this room ID.
78 pub servers: Vec<OwnedServerName>,
79}
80impl AliasResBody {
81 /// Creates a new `Response` with the given room id and servers
82 pub fn new(room_id: OwnedRoomId, servers: Vec<OwnedServerName>) -> Self {
83 Self { room_id, servers }
84 }
85}
86
87/// `PUT /_matrix/client/*/directory/room/{roomAlias}`
88///
89/// Add an alias to a room.
90/// `/v3/` ([spec])
91///
92/// [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3directoryroomroomalias
93// const METADATA: Metadata = metadata! {
94// method: PUT,
95// rate_limited: false,
96// authentication: AccessToken,
97// history: {
98// 1.0 => "/_matrix/client/r0/directory/room/:room_alias",
99// 1.1 => "/_matrix/client/v3/directory/room/:room_alias",
100// }
101// };
102
103/// Request type for the `create_alias` endpoint.
104
105#[derive(ToSchema, Deserialize, Debug)]
106pub struct SetAliasReqBody {
107 // /// The room alias to set.
108 // #[salvo(parameter(parameter_in = Path))]
109 // pub room_alias: OwnedRoomAliasId,
110 /// The room ID to set.
111 pub room_id: OwnedRoomId,
112}
113
114// `DELETE /_matrix/client/*/directory/room/{roomAlias}`
115//
116// Remove an alias from a room.
117// `/v3/` ([spec])
118//
119// [spec]: https://spec.matrix.org/latest/client-server-api/#delete_matrixclientv3directoryroomroomalias
120
121// const METADATA: Metadata = metadata! {
122// method: DELETE,
123// rate_limited: false,
124// authentication: AccessToken,
125// history: {
126// 1.0 => "/_matrix/client/r0/directory/room/:room_alias",
127// 1.1 => "/_matrix/client/v3/directory/room/:room_alias",
128// }
129// };
130
131// /// Request type for the `delete_alias` endpoint.
132
133// pub struct DeleteAliasReqArgs {
134// /// The room alias to remove.
135// #[salvo(parameter(parameter_in = Path))]
136// pub room_alias: OwnedRoomAliasId,
137// }