summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-06-18 00:17:24 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-06-18 00:17:24 +0200
commit07228d336ab74b90c39d2cf8c9e152f93bb38f7f (patch)
tree86894b4e6e6130f54766522d70af3c5185fa1095
parentSkip migration if sender_key is not a string or present (diff)
downloadnheko-07228d336ab74b90c39d2cf8c9e152f93bb38f7f.tar.xz
Support the knock_restricted rule
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt2
-rw-r--r--io.github.NhekoReborn.Nheko.yaml2
-rw-r--r--resources/qml/dialogs/RoomSettings.qml3
-rw-r--r--src/ui/RoomSettings.cpp13
-rw-r--r--src/ui/RoomSettings.h2
5 files changed, 20 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b796938b..52d762b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -579,7 +579,7 @@ if(USE_BUNDLED_MTXCLIENT)
 	FetchContent_Declare(
 		MatrixClient
 		GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
-		GIT_TAG        b26cd34fe8806f14a1daff2ca4f98474863acf9b
+		GIT_TAG        9ef7f7503c88b2a27e551324bd39a556b56aa8d6
 		)
 	set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
 	set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml
index 119e99fd..7c0d9d5f 100644
--- a/io.github.NhekoReborn.Nheko.yaml
+++ b/io.github.NhekoReborn.Nheko.yaml
@@ -203,7 +203,7 @@ modules:
     buildsystem: cmake-ninja
     name: mtxclient
     sources:
-      - commit: b26cd34fe8806f14a1daff2ca4f98474863acf9b
+      - commit: 9ef7f7503c88b2a27e551324bd39a556b56aa8d6
         #tag: v0.7.0
         type: git
         url: https://github.com/Nheko-Reborn/mtxclient.git
diff --git a/resources/qml/dialogs/RoomSettings.qml b/resources/qml/dialogs/RoomSettings.qml
index 81235fee..2818a79a 100644
--- a/resources/qml/dialogs/RoomSettings.qml
+++ b/resources/qml/dialogs/RoomSettings.qml
@@ -289,6 +289,9 @@ ApplicationWindow {
                         if (roomSettings.supportsRestricted)
                             opts.push(qsTr("Restricted by membership in other rooms"));
 
+                        if (roomSettings.supportsKnockRestricted)
+                            opts.push(qsTr("Restricted by membership in other rooms or by knocking"));
+
                         return opts;
                     }
                     currentIndex: roomSettings.accessJoinRules
diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp
index 42db1955..2d124e1e 100644
--- a/src/ui/RoomSettings.cpp
+++ b/src/ui/RoomSettings.cpp
@@ -78,6 +78,8 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
         accessRules_ = 3;
     } else if (info_.join_rule == state::JoinRule::Restricted) {
         accessRules_ = 4;
+    } else if (info_.join_rule == state::JoinRule::KnockRestricted) {
+        accessRules_ = 5;
     }
     emit accessJoinRulesChanged();
 }
@@ -263,6 +265,14 @@ RoomSettings::supportsRestricted() const
            info_.version != "3" && info_.version != "4" && info_.version != "5" &&
            info_.version != "6" && info_.version != "7";
 }
+bool
+RoomSettings::supportsKnockRestricted() const
+{
+    return info_.version != "" && info_.version != "1" && info_.version != "2" &&
+           info_.version != "3" && info_.version != "4" && info_.version != "5" &&
+           info_.version != "6" && info_.version != "7" && info_.version != "8" &&
+           info_.version != "9";
+}
 
 void
 RoomSettings::changeNotifications(int currentIndex)
@@ -349,6 +359,9 @@ RoomSettings::changeAccessRules(int index)
         case 4:
             event.join_rule = state::JoinRule::Restricted;
             break;
+        case 5:
+            event.join_rule = state::JoinRule::KnockRestricted;
+            break;
         default:
             event.join_rule = state::JoinRule::Invite;
         }
diff --git a/src/ui/RoomSettings.h b/src/ui/RoomSettings.h
index 9912cfd6..4cb5bcf4 100644
--- a/src/ui/RoomSettings.h
+++ b/src/ui/RoomSettings.h
@@ -48,6 +48,7 @@ class RoomSettings : public QObject
     Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
     Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT)
     Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT)
+    Q_PROPERTY(bool supportsKnockRestricted READ supportsKnockRestricted CONSTANT)
 
 public:
     RoomSettings(QString roomid, QObject *parent = nullptr);
@@ -74,6 +75,7 @@ public:
     bool isEncryptionEnabled() const;
     bool supportsKnocking() const;
     bool supportsRestricted() const;
+    bool supportsKnockRestricted() const;
 
     Q_INVOKABLE void enableEncryption();
     Q_INVOKABLE void updateAvatar();