[fractal/af/redact.next: 1/3] fractal-matrix-api: Handle a redacted message event



commit 25093a84d714db40cc21ea500081bf1f588cff04
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 dd0bc2d7..56b02d02 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 34a8909d..942f57a3 100644
--- a/fractal-matrix-api/src/backend/types.rs
+++ b/fractal-matrix-api/src/backend/types.rs
@@ -126,6 +126,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]