From d66f3253494b89b36c1940d18adab2d9496fc96b Mon Sep 17 00:00:00 2001
From: tastytea <tastytea@tastytea.de>
Date: Sun, 6 Mar 2022 13:04:01 +0100
Subject: [PATCH] Allow redactions to have a reason

---
 include/mtxclient/http/client.hpp | 3 ++-
 lib/http/client.cpp               | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp
index 844e1dac8..019e96380 100644
--- a/include/mtxclient/http/client.hpp
+++ b/include/mtxclient/http/client.hpp
@@ -443,7 +443,8 @@ public:
     //! Redact an event from a room.
     void redact_event(const std::string &room_id,
                       const std::string &event_id,
-                      Callback<mtx::responses::EventId> cb);
+                      Callback<mtx::responses::EventId> cb,
+                      const std::string &reason = "");
 
     //! Upload a filter
     void upload_filter(const nlohmann::json &j, Callback<mtx::responses::FilterId> cb);
diff --git a/lib/http/client.cpp b/lib/http/client.cpp
index 90428befc..d303a79d5 100644
--- a/lib/http/client.cpp
+++ b/lib/http/client.cpp
@@ -931,13 +931,18 @@ Client::read_event(const std::string &room_id,
 void
 Client::redact_event(const std::string &room_id,
                      const std::string &event_id,
-                     Callback<mtx::responses::EventId> callback)
+                     Callback<mtx::responses::EventId> callback,
+                     const std::string &reason)
 {
     const auto api_path = "/client/r0/rooms/" + mtx::client::utils::url_encode(room_id) +
                           "/redact/" + mtx::client::utils::url_encode(event_id) + "/" +
                           mtx::client::utils::url_encode(mtx::client::utils::random_token());
 
     json body = json::object();
+    if (!reason.empty()) {
+        body["reason"] = reason;
+    }
+
     put<nlohmann::json, mtx::responses::EventId>(api_path, body, std::move(callback));
 }
 
-- 
GitLab