From 947e40bd704da893f6bec84a20bc97cb069cf191 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 11 Jan 2021 19:15:43 +0100 Subject: [PATCH] Allow joins via other servers from a matrix: uri --- CMakeLists.txt | 2 +- io.github.NhekoReborn.Nheko.json | 2 +- src/ChatPage.cpp | 13 +++++++++---- src/ChatPage.h | 1 + src/dialogs/CreateRoom.cpp | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec9c8c1f..1f8b0036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -354,7 +354,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG cad81d1677a4845366b93112f8f2e267ee8c9ae0 + GIT_TAG d44158e17e8eb872bee762a81fc04bfad117f0c5 ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/io.github.NhekoReborn.Nheko.json b/io.github.NhekoReborn.Nheko.json index 7aba130b..8a74a71a 100644 --- a/io.github.NhekoReborn.Nheko.json +++ b/io.github.NhekoReborn.Nheko.json @@ -152,7 +152,7 @@ "name": "mtxclient", "sources": [ { - "commit": "cad81d1677a4845366b93112f8f2e267ee8c9ae0", + "commit": "d44158e17e8eb872bee762a81fc04bfad117f0c5", "type": "git", "url": "https://github.com/Nheko-Reborn/mtxclient.git" } diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 33c993ae..4e70411d 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -900,9 +900,14 @@ void ChatPage::joinRoom(const QString &room) { const auto room_id = room.toStdString(); + joinRoomVia(room_id, {}); +} +void +ChatPage::joinRoomVia(const std::string &room_id, const std::vector &via) +{ http::client()->join_room( - room_id, [this, room_id](const mtx::responses::RoomId &, mtx::http::RequestErr err) { + room_id, via, [this, room_id](const mtx::responses::RoomId &, mtx::http::RequestErr err) { if (err) { emit showNotification( tr("Failed to join room: %1") @@ -1291,7 +1296,7 @@ ChatPage::startChat(QString userid) mtx::requests::CreateRoom req; req.preset = mtx::requests::Preset::PrivateChat; - req.visibility = mtx::requests::Visibility::Private; + req.visibility = mtx::common::RoomVisibility::Private; if (utils::localUser() != userid) req.invite = {userid.toStdString()}; emit ChatPage::instance()->createRoom(req); @@ -1380,7 +1385,7 @@ ChatPage::handleMatrixUri(const QByteArray &uri) } if (action == "join") { - joinRoom(mxid1); + joinRoomVia(targetRoomId, vias); } } else if (sigil1 == "room") { auto joined_rooms = cache::joinedRooms(); @@ -1398,7 +1403,7 @@ ChatPage::handleMatrixUri(const QByteArray &uri) } if (action == "join") { - joinRoom(mxid1); + joinRoomVia(mxid1.toStdString(), vias); } } } diff --git a/src/ChatPage.h b/src/ChatPage.h index 004bb3e8..0516f87d 100644 --- a/src/ChatPage.h +++ b/src/ChatPage.h @@ -117,6 +117,7 @@ public slots: void leaveRoom(const QString &room_id); void createRoom(const mtx::requests::CreateRoom &req); void joinRoom(const QString &room); + void joinRoomVia(const std::string &room_id, const std::vector &via); void inviteUser(QString userid, QString reason); void kickUser(QString userid, QString reason); diff --git a/src/dialogs/CreateRoom.cpp b/src/dialogs/CreateRoom.cpp index 459405ce..fed46e02 100644 --- a/src/dialogs/CreateRoom.cpp +++ b/src/dialogs/CreateRoom.cpp @@ -115,9 +115,9 @@ CreateRoom::CreateRoom(QWidget *parent) static_cast(&QComboBox::currentTextChanged), [this](const QString &text) { if (text == "Private") { - request_.visibility = mtx::requests::Visibility::Private; + request_.visibility = mtx::common::RoomVisibility::Private; } else { - request_.visibility = mtx::requests::Visibility::Public; + request_.visibility = mtx::common::RoomVisibility::Public; } });