[fractal] fractal-matrix-api: Handle a redacted message event



commit c95bd28dbed155197b0d93949c177c159ae288a6
Author: Alistair Francis <alistair alistair23 me>
Date:   Wed Aug 21 22:39:18 2019 -0700

    fractal-matrix-api: Handle a redacted message event
    
    Signed-off-by: Alistair Francis <alistair alistair23 me>

 fractal-gtk/src/app/backend_loop.rs     |  3 +++
 fractal-matrix-api/src/backend/sync.rs  | 10 ++++++++++
 fractal-matrix-api/src/backend/types.rs |  1 +
 fractal-matrix-api/src/model/event.rs   |  1 +
 4 files changed, 15 insertions(+)
---
diff --git a/fractal-gtk/src/app/backend_loop.rs b/fractal-gtk/src/app/backend_loop.rs
index dcc87d5c..51f9c04e 100644
--- a/fractal-gtk/src/app/backend_loop.rs
+++ b/fractal-gtk/src/app/backend_loop.rs
@@ -150,6 +150,9 @@ pub fn backend_loop(rx: Receiver<BKResponse>) {
                 BKResponse::SetRoomAvatar(Ok(_)) => {
                     APPOP!(show_new_room_avatar);
                 }
+                BKResponse::RemoveMessage(Ok((room, msg))) => {
+                    APPOP!(remove_message, (room, msg));
+                }
                 BKResponse::MarkedAsRead(Ok((r, _))) => {
                     APPOP!(clear_room_notifications, (r));
                 }
diff --git a/fractal-matrix-api/src/backend/sync.rs b/fractal-matrix-api/src/backend/sync.rs
index e50163b3..32564381 100644
--- a/fractal-matrix-api/src/backend/sync.rs
+++ b/fractal-matrix-api/src/backend/sync.rs
@@ -192,6 +192,10 @@ pub fn sync(
                                         .map(Into::into)
                                         .unwrap_or_default(),
                                     content: ev["content"].clone(),
+                                    redacts: ev["redacts"]
+                                        .as_str()
+                                        .map(Into::into)
+                                        .unwrap_or_default(),
                                     stype: ev["type"].as_str().map(Into::into).unwrap_or_default(),
                                     id: ev["id"].as_str().map(Into::into).unwrap_or_default(),
                                 })
@@ -225,6 +229,12 @@ pub fn sync(
                                 "m.sticker" => {
                                     // This event is managed in the room list
                                 }
+                                "m.room.redaction" => {
+                                    let _ = tx.send(BKResponse::RemoveMessage(Ok((
+                                        ev.room.clone(),
+                                        ev.redacts,
+                                    ))));
+                                }
                                 _ => {
                                     error!("EVENT NOT MANAGED: {:?}", ev);
                                 }
diff --git a/fractal-matrix-api/src/backend/types.rs b/fractal-matrix-api/src/backend/types.rs
index 928381cf..1d05bd04 100644
--- a/fractal-matrix-api/src/backend/types.rs
+++ b/fractal-matrix-api/src/backend/types.rs
@@ -127,6 +127,7 @@ pub enum BKResponse {
     SetRoomName(Result<(), Error>),
     SetRoomTopic(Result<(), Error>),
     SetRoomAvatar(Result<(), Error>),
+    RemoveMessage(Result<(String, String), Error>),
     RoomName(String, String),
     RoomTopic(String, String),
     Media(Result<String, Error>),
diff --git a/fractal-matrix-api/src/model/event.rs b/fractal-matrix-api/src/model/event.rs
index 5cb622ac..cdd20e64 100644
--- a/fractal-matrix-api/src/model/event.rs
+++ b/fractal-matrix-api/src/model/event.rs
@@ -6,6 +6,7 @@ pub struct Event {
     pub stype: String,
     pub room: String,
     pub id: String,
+    pub redacts: String,
     pub content: JsonValue,
 }
 


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