From 78d5e3526ba418c6c45755b7e68d6ecc7688ebd2 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 22 Oct 2024 15:30:38 +0200 Subject: [PATCH] chore(media): use the same media method when caching a thumbnail as the default one used in the FFI The FFI will request a scaled version of the thumbnail by default; let's use the same cache key when caching the thumbnail after an upload. Thanks @zecakeh for flagging the issue. --- crates/matrix-sdk/src/room/mod.rs | 2 +- crates/matrix-sdk/tests/integration/room/attachment/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/matrix-sdk/src/room/mod.rs b/crates/matrix-sdk/src/room/mod.rs index b6588f15f0f..1fa314d473c 100644 --- a/crates/matrix-sdk/src/room/mod.rs +++ b/crates/matrix-sdk/src/room/mod.rs @@ -1996,7 +1996,7 @@ impl Room { source: source.clone(), format: MediaFormat::Thumbnail(MediaThumbnailSettings { size: MediaThumbnailSize { - method: ruma::media::Method::Crop, + method: ruma::media::Method::Scale, width, height, }, diff --git a/crates/matrix-sdk/tests/integration/room/attachment/mod.rs b/crates/matrix-sdk/tests/integration/room/attachment/mod.rs index 31e2d395958..252721f6d5d 100644 --- a/crates/matrix-sdk/tests/integration/room/attachment/mod.rs +++ b/crates/matrix-sdk/tests/integration/room/attachment/mod.rs @@ -250,7 +250,7 @@ async fn test_room_attachment_send_info_thumbnail() { source: MediaSource::Plain(thumbnail_mxc.clone()), format: MediaFormat::Thumbnail(MediaThumbnailSettings { size: MediaThumbnailSize { - method: ruma::media::Method::Crop, + method: ruma::media::Method::Scale, width: uint!(480), height: uint!(360), }, @@ -284,7 +284,7 @@ async fn test_room_attachment_send_info_thumbnail() { .unwrap(); // The event was sent. - assert_eq!(event_id!("$h29iv0s8:example.com"), response.event_id); + assert_eq!(response.event_id, event_id!("$h29iv0s8:example.com")); // The media is immediately cached in the cache store, so we don't need to set // up another mock endpoint for getting the media. @@ -313,7 +313,7 @@ async fn test_room_attachment_send_info_thumbnail() { source: MediaSource::Plain(thumbnail_mxc), format: MediaFormat::Thumbnail(MediaThumbnailSettings { size: MediaThumbnailSize { - method: ruma::media::Method::Crop, + method: ruma::media::Method::Scale, width: uint!(42), height: uint!(1337), },