ruma_client_api/
media.rs

1//! Endpoints and helpers for the media repository.
2
3pub mod create_content;
4pub mod create_content_async;
5pub mod create_mxc_uri;
6pub mod get_content;
7pub mod get_content_as_filename;
8pub mod get_content_thumbnail;
9pub mod get_media_config;
10pub mod get_media_preview;
11
12/// Checks whether a given `Content-Type` is considered "safe" for having a `Content-Disposition` of
13/// `inline` returned on `/download`, as recommended by the [spec].
14///
15/// [spec]: https://spec.matrix.org/latest/client-server-api/#serving-inline-content
16pub fn is_safe_inline_content_type(content_type: &str) -> bool {
17    const SAFE_CONTENT_TYPES: [&str; 26] = [
18        "text/css",
19        "text/plain",
20        "text/csv",
21        "application/json",
22        "application/ld+json",
23        "image/jpeg",
24        "image/gif",
25        "image/png",
26        "image/apng",
27        "image/webp",
28        "image/avif",
29        "video/mp4",
30        "video/webm",
31        "video/ogg",
32        "video/quicktime",
33        "audio/mp4",
34        "audio/webm",
35        "audio/aac",
36        "audio/mpeg",
37        "audio/ogg",
38        "audio/wave",
39        "audio/wav",
40        "audio/x-wav",
41        "audio/x-pn-wav",
42        "audio/flac",
43        "audio/x-flac",
44    ];
45
46    SAFE_CONTENT_TYPES.contains(&content_type)
47}