diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp index 844e1dac8e221eed0968c5701984c639e448ef0b..019e9638004c8d67dcef7a917ae6c72a7ba97849 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 90428befc018a0b9c90874f32628361ed0bc0fab..d303a79d5411f5f0be62d30a9ed8e43d46119301 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)); }