From 6602f6114c59e47d0c2ff605493a0f7e4ffeba3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timo=20K=C3=B6sters?= <timo@koesters.xyz>
Date: Thu, 10 Feb 2022 20:59:11 +0100
Subject: [PATCH] fix: redacts can't error anymore

---
 src/database/rooms.rs |  8 ++------
 src/server_server.rs  | 10 ++++++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/database/rooms.rs b/src/database/rooms.rs
index 1f6b4316..c751167a 100644
--- a/src/database/rooms.rs
+++ b/src/database/rooms.rs
@@ -2147,13 +2147,9 @@ impl Rooms {
                 .ok_or_else(|| Error::bad_database("PDU ID points to invalid PDU."))?;
             pdu.redact(reason)?;
             self.replace_pdu(&pdu_id, &pdu)?;
-            Ok(())
-        } else {
-            Err(Error::BadRequest(
-                ErrorKind::NotFound,
-                "Event ID does not exist.",
-            ))
         }
+        // If event does not exist, just noop
+        Ok(())
     }
 
     /// Update current membership data.
diff --git a/src/server_server.rs b/src/server_server.rs
index 39210555..9f0e922b 100644
--- a/src/server_server.rs
+++ b/src/server_server.rs
@@ -1593,7 +1593,10 @@ async fn upgrade_outlier_to_timeline_pdu(
             soft_fail,
             &state_lock,
         )
-        .map_err(|_| "Failed to add pdu to db.".to_owned())?;
+        .map_err(|e| {
+            warn!("Failed to add pdu to db: {}", e);
+            "Failed to add pdu to db.".to_owned()
+        })?;
 
         // Soft fail, we keep the event as an outlier but don't add it to the timeline
         warn!("Event was soft failed: {:?}", incoming_pdu);
@@ -1759,7 +1762,10 @@ async fn upgrade_outlier_to_timeline_pdu(
         soft_fail,
         &state_lock,
     )
-    .map_err(|_| "Failed to add pdu to db.".to_owned())?;
+    .map_err(|e| {
+        warn!("Failed to add pdu to db: {}", e);
+        "Failed to add pdu to db.".to_owned()
+    })?;
 
     debug!("Appended incoming pdu.");