diff --git a/src/r0/media.rs b/src/r0/media.rs index 6fc18507..8eb4184c 100644 --- a/src/r0/media.rs +++ b/src/r0/media.rs @@ -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; diff --git a/src/r0/media/get_content.rs b/src/r0/media/get_content.rs index 338ffb50..accb0169 100644 --- a/src/r0/media/get_content.rs +++ b/src/r0/media/get_content.rs @@ -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; diff --git a/src/r0/media/get_content_as_filename.rs b/src/r0/media/get_content_as_filename.rs new file mode 100644 index 00000000..140301ea --- /dev/null +++ b/src/r0/media/get_content_as_filename.rs @@ -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, + } + + response { + /// The content that was previously uploaded. + #[ruma_api(raw_body)] + pub file: Vec, + /// 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, + } +} diff --git a/src/r0/media/get_media_config.rs b/src/r0/media/get_media_config.rs new file mode 100644 index 00000000..2cc2f086 --- /dev/null +++ b/src/r0/media/get_media_config.rs @@ -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, + } +}