From a36fe8b1ea728d6306a44fe62d6a2945caee3f0f Mon Sep 17 00:00:00 2001
From: Nicolas Werner <nicolas.werner@hotmail.de>
Date: Tue, 27 Oct 2020 15:59:39 +0100
Subject: [PATCH] Leave room sends empty response

---
 include/mtxclient/http/client.hpp |  2 +-
 lib/http/client.cpp               |  4 ++--
 tests/client_api.cpp              | 16 ++++++++--------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/mtxclient/http/client.hpp b/include/mtxclient/http/client.hpp
index 79990e61a..b82e7c0df 100644
--- a/include/mtxclient/http/client.hpp
+++ b/include/mtxclient/http/client.hpp
@@ -319,7 +319,7 @@ public:
         //! Join a room by an alias or a room_id.
         void join_room(const std::string &room, Callback<mtx::responses::RoomId> cb);
         //! Leave a room by its room_id.
-        void leave_room(const std::string &room_id, Callback<mtx::responses::RoomId> cb);
+        void leave_room(const std::string &room_id, Callback<mtx::responses::Empty> cb);
         //! Invite a user to a room.
         void invite_user(const std::string &room_id,
                          const std::string &user_id,
diff --git a/lib/http/client.cpp b/lib/http/client.cpp
index 10837e7a3..d3f29975a 100644
--- a/lib/http/client.cpp
+++ b/lib/http/client.cpp
@@ -608,11 +608,11 @@ Client::join_room(const std::string &room, Callback<mtx::responses::RoomId> call
 }
 
 void
-Client::leave_room(const std::string &room_id, Callback<mtx::responses::RoomId> callback)
+Client::leave_room(const std::string &room_id, Callback<mtx::responses::Empty> callback)
 {
         auto api_path = "/client/r0/rooms/" + mtx::client::utils::url_encode(room_id) + "/leave";
 
-        post<std::string, mtx::responses::RoomId>(api_path, "{}", callback);
+        post<std::string, mtx::responses::Empty>(api_path, "{}", callback);
 }
 
 void
diff --git a/tests/client_api.cpp b/tests/client_api.cpp
index 3ba4f6186..1d4dab26c 100644
--- a/tests/client_api.cpp
+++ b/tests/client_api.cpp
@@ -542,18 +542,18 @@ TEST(ClientAPI, LeaveRoom)
                                        check_error(err);
 
                                        bob->leave_room(room_id.to_string(),
-                                                       [](const mtx::responses::RoomId &,
-                                                          RequestErr err) { check_error(err); });
+                                                       [](mtx::responses::Empty, RequestErr err) {
+                                                               check_error(err);
+                                                       });
                                });
         });
 
         // Trying to leave a non-existent room should fail.
-        bob->leave_room(
-          "!random_room_id:localhost", [](const mtx::responses::RoomId &, RequestErr err) {
-                  ASSERT_TRUE(err);
-                  EXPECT_EQ(mtx::errors::to_string(err->matrix_error.errcode), "M_UNKNOWN");
-                  EXPECT_EQ(err->matrix_error.error, "Not a known room");
-          });
+        bob->leave_room("!random_room_id:localhost", [](mtx::responses::Empty, RequestErr err) {
+                ASSERT_TRUE(err);
+                EXPECT_EQ(mtx::errors::to_string(err->matrix_error.errcode), "M_UNKNOWN");
+                EXPECT_EQ(err->matrix_error.error, "Not a known room");
+        });
 
         alice->close();
         bob->close();
-- 
GitLab