Add missing media endpoints

Fixes #73.
This commit is contained in:
Isaiah Inuwa 2020-02-19 13:21:34 -06:00
parent bb52edf1e0
commit ed508c043e
4 changed files with 68 additions and 3 deletions

View File

@ -2,4 +2,6 @@
pub mod create_content;
pub mod get_content;
pub mod get_content_as_filename;
pub mod get_content_thumbnail;
pub mod get_media_config;

View File

@ -1,6 +1,4 @@
//! Endpoints for the media repository.
//! [GET /_matrix/media/r0/download/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-media-r0-download-servername-mediaid)
//! [GET /_matrix/media/r0/download/{serverName}/{mediaId}](https://matrix.org/docs/spec/client_server/r0.6.0.html#get-matrix-media-r0-download-servername-mediaid)
use ruma_api::ruma_api;

View File

@ -0,0 +1,42 @@
//! [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;
ruma_api! {
metadata {
description: "Retrieve content from the media store, specifying a filename to return.",
method: GET,
name: "get_media_content_as_filename",
path: "/_matrix/media/r0/download/:server_name/:media_id/:filename",
rate_limited: false,
requires_authentication: false,
}
request {
/// The media ID from the mxc:// URI (the path component).
#[ruma_api(path)]
pub media_id: String,
/// The server name from the mxc:// URI (the authoritory component).
#[ruma_api(path)]
pub server_name: String,
/// The filename to return in the `Content-Disposition` header.
#[ruma_api(path)]
pub filename: String,
/// Whether to fetch media deemed remote.
/// Used to prevent routing loops. Defaults to `true`.
#[ruma_api(query)]
pub allow_remote: Option<bool>,
}
response {
/// The content that was previously uploaded.
#[ruma_api(raw_body)]
pub file: Vec<u8>,
/// The content type of the file that was previously uploaded.
#[ruma_api(header = CONTENT_TYPE)]
pub content_type: String,
/// The name of the file that was previously uploaded, if set.
#[ruma_api(header = CONTENT_DISPOSITION)]
pub content_disposition: String,
}
}

View File

@ -0,0 +1,23 @@
//! [GET /_matrix/media/r0/config](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-media-r0-config)
use js_int::UInt;
use ruma_api::ruma_api;
ruma_api! {
metadata {
description: "Gets the config for the media repository.",
method: GET,
path: "/_matrix/media/r0/config",
name: "get_media_config",
rate_limited: true,
requires_authentication: true,
}
request {}
response {
/// Maximum size of upload in bytes.
#[serde(rename = "m.upload.size")]
upload_size: UInt,
}
}