Compare commits

..

3 commits

2 changed files with 62 additions and 27 deletions

View file

@ -1,11 +1,11 @@
# r0.5.0
# Implementation Process (r0.5.0)
- [ ] 2 API Standards
- [x] ~~2.1 GET /_matrix/client/versions~~
- [x] ~~3 Web Browser Clients~~ *Not applicable*
- [ ] 4 Server Discovery
- [ ] 4.1 Well-known URI
- [ ] 4.1.1 GET /.well-known/matrix/client
- [x] ~~4.1.1 GET /.well-known/matrix/client~~
- [ ] 5 Client Authentication
- [x] ~~5.1 Using access tokens~~ *Only through Authorization header*
- [ ] 5.2 Relationship between access tokens and devices
@ -87,7 +87,7 @@
- [ ] 9.5.4 GET /_matrix/client/r0/rooms/{roomId}/members
- [ ] 9.5.5 GET /_matrix/client/r0/rooms/{roomId}/joined_members
- [ ] 9.5.6 GET /_matrix/client/r0/rooms/{roomId}/messages
- [ ] 9.5.7 GET /_matrix/client/r0/rooms/{roomId}/initialSync
- [x] ~~9.5.7 GET /_matrix/client/r0/rooms/{roomId}/initialSync~~ *Deprecated*
- [ ] 9.6 Sending events to a room
- [ ] 9.6.1 PUT /_matrix/client/r0/rooms/{roomId}/state/{eventType}/{stateKey}
- [ ] 9.6.2 PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}
@ -175,7 +175,7 @@
- [ ] 13.2.2.6.1.1.2 Fallback for m.text, m.notice, and unrecognised message types
- [ ] 13.2.2.6.1.1.3 Fallback for m.emote
- [ ] 13.2.2.6.1.1.4 Fallback for m.image, m.video, m.audio, and m.file
- [ ] 13.2.3 Server behaviour
- [ ] 13.2.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.2.4 Security considerations
- [ ] 13.3 Voice over IP
- [ ] 13.3.1 Events
@ -185,7 +185,7 @@
- [ ] 13.3.1.4 m.call.hangup
- [ ] 13.3.2 Client behaviour
- [ ] 13.3.2.1 Glare
- [ ] 13.3.3 Server behaviour
- [ ] 13.3.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.3.3.1 GET /_matrix/client/r0/voip/turnServer
- [ ] 13.3.4 Security considerations
- [ ] 13.4 Typing Notifications
@ -199,14 +199,14 @@
- [ ] 13.5.1.1 m.receipt
- [ ] 13.5.2 Client behaviour
- [ ] 13.5.2.1 POST /_matrix/client/r0/rooms/{roomId}/receipt/{receiptType}/{eventId}
- [ ] 13.5.3 Server behaviour
- [ ] 13.5.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.5.4 Security considerations
- [ ] 13.6 Fully read markers
- [ ] 13.6.1 Events
- [ ] 13.6.1.1 m.fully_read
- [ ] 13.6.2 Client behaviour
- [ ] 13.6.2.1 POST /_matrix/client/r0/rooms/{roomId}/read_markers
- [ ] 13.6.3 Server behaviour
- [ ] 13.6.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.7 Presence
- [ ] 13.7.1 Events
- [ ] 13.7.1.1 m.presence
@ -229,7 +229,7 @@
- [ ] 13.8.3 Security considerations
- [ ] 13.9 Send-to-Device messaging
- [ ] 13.9.1 Client behaviour
- [ ] 13.9.2 Server behaviour
- [ ] 13.9.2 ~~Server behaviour~~ *Not applicable*
- [ ] 13.9.3 Protocol definitions
- [ ] 13.9.3.1 PUT /_matrix/client/r0/sendToDevice/{eventType}/{txnId}
- [ ] 13.9.3.2 Extensions to /sync
@ -293,7 +293,7 @@
- [ ] 13.12.1 Events
- [ ] 13.12.1.1 m.room.history_visibility
- [ ] 13.12.2 Client behaviour
- [ ] 13.12.3 Server behaviour
- [ ] 13.12.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.12.4 Security considerations
- [ ] 13.13 Push Notifications
- [ ] 13.13.1 Client behaviour
@ -335,7 +335,7 @@
- [ ] 13.13.1.7 Push Rules: Events
- [ ] 13.13.1.7.1 m.push_rules
- [ ] 13.13.1.7.2 Examples
- [ ] 13.13.2 Server behaviour
- [ ] 13.13.2 ~~Server behaviour~~ *Not applicable*
- [ ] 13.13.3 Push Gateway behaviour
- [ ] 13.13.3.1 Recommendations for APNS
- [ ] 13.13.4 Security considerations
@ -344,7 +344,7 @@
- [ ] 13.14.1.1 m.room.third_party_invite
- [ ] 13.14.2 Client behaviour
- [ ] 13.14.2.1 POST /_matrix/client/r0/rooms/{roomId}/invite
- [ ] 13.14.3 Server behaviour
- [ ] 13.14.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.14.4 Security considerations
- [ ] 13.15 Server Side Search
- [ ] 13.15.1 Client behaviour
@ -359,12 +359,12 @@
- [ ] 13.16.1 Events
- [ ] 13.16.1.1 m.room.guest_access
- [ ] 13.16.2 Client behaviour
- [ ] 13.16.3 Server behaviour
- [ ] 13.16.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.16.4 Security considerations
- [ ] 13.17 Room Previews
- [ ] 13.17.1 Client behaviour
- [ ] 13.17.1.1 GET /_matrix/client/r0/events
- [ ] 13.17.2 Server behaviour
- [ ] 13.17.2 ~~Server behaviour~~ *Not applicable*
- [ ] 13.17.3 Security considerations
- [ ] 13.18 Room Tagging
- [ ] 13.18.1 Events
@ -380,7 +380,7 @@
- [ ] 13.19.2.2 GET /_matrix/client/r0/user/{userId}/account_data/{type}
- [ ] 13.19.2.3 PUT /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}
- [ ] 13.19.2.4 GET /_matrix/client/r0/user/{userId}/rooms/{roomId}/account_data/{type}
- [ ] 13.19.3 Server Behaviour
- [ ] 13.19.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.20 Server Administration
- [ ] 13.20.1 Client Behaviour
- [ ] 13.20.1.1 GET /_matrix/client/r0/admin/whois/{userId}
@ -391,19 +391,19 @@
- [ ] 13.22 SSO client login
- [ ] 13.22.1 Client behaviour
- [ ] 13.22.1.1 GET /_matrix/client/r0/login/sso/redirect
- [ ] 13.22.2 Server behaviour
- [ ] 13.22.2 ~~Server behaviour~~ *Not applicable*
- [ ] 13.22.2.1 Handling the redirect endpoint
- [ ] 13.22.2.2 Handling the authentication endpoint
- [ ] 13.23 Direct Messaging
- [ ] 13.23.1 Events
- [ ] 13.23.1.1 m.direct
- [ ] 13.23.2 Client behaviour
- [ ] 13.23.3 Server behaviour
- [ ] 13.23.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.24 Ignoring Users
- [ ] 13.24.1 Events
- [ ] 13.24.1.1 m.ignored_user_list
- [ ] 13.24.2 Client behaviour
- [ ] 13.24.3 Server behaviour
- [ ] 13.24.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.25 Sticker Messages
- [ ] 13.25.1 Events
- [ ] 13.25.1.1 m.sticker
@ -411,7 +411,7 @@
- [ ] 13.26 Reporting Content
- [ ] 13.26.1 Client behaviour
- [ ] 13.26.1.1 POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}
- [ ] 13.26.2 Server behaviour
- [ ] 13.26.2 ~~Server behaviour~~ *Not applicable*
- [ ] 13.27 Third Party Networks
- [ ] 13.27.1 Third Party Lookups
- [ ] 13.27.1.1 GET /_matrix/client/r0/thirdparty/protocols
@ -425,7 +425,7 @@
- [ ] 13.29 Server Access Control Lists (ACLs) for rooms
- [ ] 13.29.1 m.room.server_acl
- [ ] 13.29.2 Client behaviour
- [ ] 13.29.3 Server behaviour
- [ ] 13.29.3 ~~Server behaviour~~ *Not applicable*
- [ ] 13.29.4 Security considerations
- [ ] 13.30 User, room, and group mentions
- [ ] 13.30.1 Client behaviour
@ -434,9 +434,9 @@
- [ ] 13.31.1.1 m.room.tombstone
- [ ] 13.31.2 Client behaviour
- [ ] 13.31.2.1 POST /_matrix/client/r0/rooms/{roomId}/upgrade
- [ ] 13.31.3 Server behaviour
- [x] ~~13.31.3 Server behaviour~~ *Not applicable*
- [ ] 13.32 Server Notices
- [ ] 13.32.1 Events
- [ ] 13.32.1.1 m.room.message (m.server_notice)
- [ ] 13.32.2 Client behaviour
- [ ] 13.32.3 Server behaviour
- [x] ~~13.32.3 Server behaviour~~ *Not applicable*

View file

@ -68,6 +68,23 @@ pub struct SupportedSpecs {
pub unstable_features: Option<HashMap<String, bool>>,
}
#[derive(Deserialize)]
pub struct DiscoveryInformation {
#[serde(rename = "m.homeserver")]
homeserver: HomeserverInformation,
identity_server: Option<IdentityServerInformation>,
}
#[derive(Deserialize)]
pub struct HomeserverInformation {
base_url: String,
}
#[derive(Deserialize)]
pub struct IdentityServerInformation {
base_url: String,
}
impl Client {
pub fn new(
homeserver_url: &str,
@ -100,15 +117,33 @@ impl Client {
Ok(client)
}
/// Implementation of [Section 2.1 **GET** /_matrix/client/versions](https://matrix.org/docs/spec/client_server/r0.5.0#get-matrix-client-versions).
/// Implementation of [Section 4.1.1 **GET** `/.well-known/matrix/client`](https://matrix.org/docs/spec/client_server/r0.5.0#get-well-known-matrix-client).
///
/// This does not implement the expected behavior a client *should* perform
/// as described in [Section 4.1 Well-Known URI](https://matrix.org/docs/spec/client_server/r0.5.0#well-known-uri).
/// Higher level clients must implement this behavior.
pub fn discovery_information(&self) -> Result<DiscoveryInformation, Box<dyn Error>> {
Ok(self
.send(
MatrixHTTPMethod::Get,
"/.well-known/matrix/client",
None,
None,
None,
)?
.json()?)
}
/// Implementation of [Section 2.1 **GET** `/_matrix/client/versions`](https://matrix.org/docs/spec/client_server/r0.5.0#get-matrix-client-versions).
///
/// Returns a list of matrix specifications a server supports, as well as
/// a map of unstable features the server has advertised.
/// a map of unstable features the server has advertised. This is not rate-
/// limited nor requires authorization.
pub fn supported_versions(&self) -> Result<SupportedSpecs, Box<dyn Error>> {
Ok(self
.send(
MatrixHTTPMethod::Get,
Some("/_matrix/client/versions"),
"/_matrix/client/versions",
None,
None,
None,
@ -130,7 +165,7 @@ impl Client {
fn send(
&self,
method: MatrixHTTPMethod,
path: Option<&str>,
path: &str,
content: Option<String>,
query_params: Option<HashMap<String, String>>,
headers: Option<HeaderMap>,
@ -143,7 +178,7 @@ impl Client {
#[cfg(not(test))]
let url = &self.homeserver_url;
let endpoint = &format!("{}{}", url, path.unwrap_or_else(|| V2_API_PATH));
let endpoint = &format!("{}{}", url, path);
let mut request = match method {
MatrixHTTPMethod::Get => self.reqwest_client.get(endpoint),
MatrixHTTPMethod::Put => self.reqwest_client.put(endpoint),
@ -209,7 +244,7 @@ impl Client {
path: &str,
query_params: HashMap<String, String>,
) -> Result<Response, Box<dyn Error>> {
self.send(method, Some(path), None, Some(query_params), None)
self.send(method, path, None, Some(query_params), None)
}
pub fn sync(