[fractal/fix-image-upload: 1/2] API: Fix thumbnail_url modification on image upload



commit ffc09548ed2dff3598b312d06762e2f1b4d1b122
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Thu Jan 9 10:11:45 2020 +0100

    API: Fix thumbnail_url modification on image upload
    
    We were updating a clone of extra_content struct so we never modified
    the thumbnail_url field. This patch modifies the struct in place instead
    of cloning.
    
    See https://gitlab.gnome.org/GNOME/fractal/issues/572

 fractal-matrix-api/src/backend/room.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/fractal-matrix-api/src/backend/room.rs b/fractal-matrix-api/src/backend/room.rs
index 942deeca..d4c5681a 100644
--- a/fractal-matrix-api/src/backend/room.rs
+++ b/fractal-matrix-api/src/backend/room.rs
@@ -703,8 +703,10 @@ pub fn attach_file(
                 }
                 Ok(thumb_uri) => {
                     msg.thumb = Some(thumb_uri.to_string());
-                    extra_content.clone().unwrap().info.thumbnail_url = Some(thumb_uri);
-                    msg.extra_content = Some(serde_json::to_value(&extra_content).unwrap());
+                    if let Some(mut xctx) = extra_content {
+                        xctx.info.thumbnail_url = Some(thumb_uri);
+                        msg.extra_content = Some(serde_json::to_value(&xctx).unwrap());
+                    }
                 }
             }
             if let Err(_e) = std::fs::remove_file(&thumb) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]