Support the knock_restricted rule

This commit is contained in:
Nicolas Werner 2022-06-18 00:17:24 +02:00
parent b57152a1c9
commit 07228d336a
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
5 changed files with 20 additions and 2 deletions

View File

@ -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 "")

View File

@ -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

View File

@ -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

View File

@ -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;
}

View File

@ -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();