client-api: Add constructors with MxcUri in media::get_content*::Request

This commit is contained in:
Kévin Commaille 2021-04-05 11:40:27 +02:00 committed by GitHub
parent b1470261e0
commit 20fb7c3c82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -89,6 +89,14 @@ Improvements:
* `r0::message::get_message_events`
* Add `logout_devices` field to `r0::account::change_password`
* Add `r0::room::aliases` (introduced in r0.6.1)
* Add constructors that use `ruma_identifiers::MxcUri` for `Request` in the following endpoints:
```rust
r0::media::{
get_content,
get_content_as_filename,
get_content_thumbnail
}
```
# 0.9.0

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/media/r0/download/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-media-r0-download-servername-mediaid)
use ruma_api::ruma_api;
use ruma_identifiers::ServerName;
use ruma_identifiers::{MxcUri, ServerName};
ruma_api! {
metadata: {
@ -57,6 +57,11 @@ impl<'a> Request<'a> {
pub fn new(media_id: &'a str, server_name: &'a ServerName) -> Self {
Self { media_id, server_name, allow_remote: true }
}
/// Creates a new `Request` with the given url.
pub fn from_url(url: &'a MxcUri) -> Self {
Self { media_id: url.media_id(), server_name: url.server_name(), allow_remote: true }
}
}
impl Response {

View File

@ -1,7 +1,7 @@
//! [GET /_matrix/media/r0/download/{serverName}/{mediaId}/{fileName}](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-media-r0-download-servername-mediaid-filename)
use ruma_api::ruma_api;
use ruma_identifiers::ServerName;
use ruma_identifiers::{MxcUri, ServerName};
ruma_api! {
metadata: {
@ -62,6 +62,16 @@ impl<'a> Request<'a> {
pub fn new(media_id: &'a str, server_name: &'a ServerName, filename: &'a str) -> Self {
Self { media_id, server_name, filename, allow_remote: true }
}
/// Creates a new `Request` with the given url and filename.
pub fn from_url(url: &'a MxcUri, filename: &'a str) -> Self {
Self {
media_id: url.media_id(),
server_name: url.server_name(),
filename,
allow_remote: true,
}
}
}
impl Response {

View File

@ -2,7 +2,7 @@
use js_int::UInt;
use ruma_api::ruma_api;
use ruma_identifiers::ServerName;
use ruma_identifiers::{MxcUri, ServerName};
use ruma_serde::StringEnum;
/// The desired resizing method.
@ -80,6 +80,19 @@ impl<'a> Request<'a> {
pub fn new(media_id: &'a str, server_name: &'a ServerName, width: UInt, height: UInt) -> Self {
Self { media_id, server_name, method: None, width, height, allow_remote: true }
}
/// Creates a new `Request` with the given url, desired thumbnail width and
/// desired thumbnail height.
pub fn from_url(url: &'a MxcUri, width: UInt, height: UInt) -> Self {
Self {
media_id: url.media_id(),
server_name: url.server_name(),
method: None,
width,
height,
allow_remote: true,
}
}
}
impl Response {