diff --git a/ruma-client-api/src/r0/media/create_content.rs b/ruma-client-api/src/r0/media/create_content.rs index 416eaf18..fa039bfe 100644 --- a/ruma-client-api/src/r0/media/create_content.rs +++ b/ruma-client-api/src/r0/media/create_content.rs @@ -30,6 +30,15 @@ ruma_api! { response: { /// The MXC URI for the uploaded content. pub content_uri: String, + + /// The [BlurHash](https://blurha.sh) for the uploaded content. + /// + /// This uses the unstable prefix in + /// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448). + #[cfg(feature = "unstable-pre-spec")] + #[serde(rename = "xyz.amorgan.blurhash")] + #[serde(skip_serializing_if = "Option::is_none")] + pub blurhash: Option, } error: crate::Error @@ -45,6 +54,10 @@ impl<'a> Request<'a> { impl Response { /// Creates a new `Response` with the given MXC URI. pub fn new(content_uri: String) -> Self { - Self { content_uri } + Self { + content_uri, + #[cfg(feature = "unstable-pre-spec")] + blurhash: None, + } } } diff --git a/ruma-events/src/room.rs b/ruma-events/src/room.rs index 7bb20ba7..9331988b 100644 --- a/ruma-events/src/room.rs +++ b/ruma-events/src/room.rs @@ -58,6 +58,15 @@ pub struct ImageInfo { /// Information on the encrypted thumbnail image. Only present if the thumbnail is encrypted. #[serde(skip_serializing_if = "Option::is_none")] pub thumbnail_file: Option>, + + /// The [BlurHash](https://blurha.sh) for this image. + /// + /// This uses the unstable prefix in + /// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448). + #[cfg(feature = "unstable-pre-spec")] + #[serde(rename = "xyz.amorgan.blurhash")] + #[serde(skip_serializing_if = "Option::is_none")] + pub blurhash: Option, } /// Metadata about a thumbnail. diff --git a/ruma-events/src/room/message.rs b/ruma-events/src/room/message.rs index 1ee3e57b..cc304233 100644 --- a/ruma-events/src/room/message.rs +++ b/ruma-events/src/room/message.rs @@ -544,6 +544,15 @@ pub struct VideoInfo { /// Information on the encrypted thumbnail file. Only present if the thumbnail is encrypted. #[serde(skip_serializing_if = "Option::is_none")] pub thumbnail_file: Option>, + + /// The [BlurHash](https://blurha.sh) for this video. + /// + /// This uses the unstable prefix in + /// [MSC2448](https://github.com/matrix-org/matrix-doc/pull/2448). + #[cfg(feature = "unstable-pre-spec")] + #[serde(rename = "xyz.amorgan.blurhash")] + #[serde(skip_serializing_if = "Option::is_none")] + pub blurhash: Option, } /// The payload for a key verification request message. diff --git a/ruma-events/tests/event_enums.rs b/ruma-events/tests/event_enums.rs index 4841eeca..fc4bb705 100644 --- a/ruma-events/tests/event_enums.rs +++ b/ruma-events/tests/event_enums.rs @@ -84,6 +84,8 @@ fn serialize_message_event() { })), thumbnail_url: Some("mxc://matrix.org".into()), thumbnail_file: None, + #[cfg(feature = "unstable-pre-spec")] + blurhash: None, }, url: "http://www.matrix.org".into(), }, diff --git a/ruma-events/tests/message_event.rs b/ruma-events/tests/message_event.rs index 0f984c37..d7760516 100644 --- a/ruma-events/tests/message_event.rs +++ b/ruma-events/tests/message_event.rs @@ -30,6 +30,8 @@ fn message_serialize_sticker() { })), thumbnail_url: Some("mxc://matrix.org".into()), thumbnail_file: None, + #[cfg(feature = "unstable-pre-spec")] + blurhash: None, }, url: "http://www.matrix.org".into(), }), @@ -189,6 +191,8 @@ fn deserialize_message_sticker() { thumbnail_info: Some(thumbnail_info), thumbnail_url: Some(thumbnail_url), thumbnail_file: None, + #[cfg(feature = "unstable-pre-spec")] + blurhash: None, }, url, }), diff --git a/ruma-events/tests/state_event.rs b/ruma-events/tests/state_event.rs index f2137d1b..b5f56ce8 100644 --- a/ruma-events/tests/state_event.rs +++ b/ruma-events/tests/state_event.rs @@ -220,6 +220,8 @@ fn deserialize_avatar_without_prev_content() { thumbnail_info: Some(thumbnail_info), thumbnail_url: Some(thumbnail_url), thumbnail_file: None, + #[cfg(feature = "unstable-pre-spec")] + blurhash: None, } if *height == UInt::new(423) && *width == UInt::new(1011) && *mimetype == "image/png"