summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-02-24 01:37:26 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-02-24 01:37:26 +0100
commit29a71741f4c0effd61f82b4e9897ba29529a8b6b (patch)
tree4e72984fc1893ad37286e13a2c7f3a6d58f06c5e /src
parentAdd missing dependency to appimage (diff)
downloadnheko-29a71741f4c0effd61f82b4e9897ba29529a8b6b.tar.xz
Ensure we ask for confirmation when clicking on a matrix uri
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp
index 9c814bd1..9ba2cc87 100644
--- a/src/ChatPage.cpp
+++ b/src/ChatPage.cpp
@@ -920,6 +920,13 @@ ChatPage::joinRoom(const QString &room)
 void
 ChatPage::joinRoomVia(const std::string &room_id, const std::vector<std::string> &via)
 {
+        if (QMessageBox::Yes !=
+            QMessageBox::question(
+              this,
+              tr("Confirm join"),
+              tr("Do you really want to join %1?").arg(QString::fromStdString(room_id))))
+                return;
+
         http::client()->join_room(
           room_id, via, [this, room_id](const mtx::responses::RoomId &, mtx::http::RequestErr err) {
                   if (err) {
@@ -1308,6 +1315,13 @@ ChatPage::startChat(QString userid)
                 }
         }
 
+        if (QMessageBox::Yes !=
+            QMessageBox::question(
+              this,
+              tr("Confirm invite"),
+              tr("Do you really want to start a private chat with %1?").arg(userid)))
+                return;
+
         mtx::requests::CreateRoom req;
         req.preset     = mtx::requests::Preset::PrivateChat;
         req.visibility = mtx::common::RoomVisibility::Private;
@@ -1362,7 +1376,7 @@ ChatPage::handleMatrixUri(const QByteArray &uri)
                 return;
 
         QString mxid2;
-        if (segments.size() == 4 && segments[2] == "e") {
+        if (segments.size() == 4 && segments[2] == "event") {
                 if (segments[3].isEmpty())
                         return;
                 else
@@ -1400,7 +1414,7 @@ ChatPage::handleMatrixUri(const QByteArray &uri)
                         }
                 }
 
-                if (action == "join") {
+                if (action == "join" || action.isEmpty()) {
                         joinRoomVia(targetRoomId, vias);
                 }
         } else if (sigil1 == "r") {
@@ -1418,7 +1432,7 @@ ChatPage::handleMatrixUri(const QByteArray &uri)
                         }
                 }
 
-                if (action == "join") {
+                if (action == "join" || action.isEmpty()) {
                         joinRoomVia(mxid1.toStdString(), vias);
                 }
         }