Allow accepting knocks in the timeline

As well as selecting more join rules.
This commit is contained in:
Nicolas Werner 2021-08-17 23:31:25 +02:00
parent 56b24f8d93
commit 5b460861b1
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
8 changed files with 135 additions and 13 deletions

View file

@ -218,8 +218,12 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
} else {
accessRules_ = 1;
}
} else {
} else if (info_.join_rule == state::JoinRule::Invite) {
accessRules_ = 2;
} else if (info_.join_rule == state::JoinRule::Knock) {
accessRules_ = 3;
} else if (info_.join_rule == state::JoinRule::Restricted) {
accessRules_ = 4;
}
emit accessJoinRulesChanged();
}
@ -368,6 +372,21 @@ RoomSettings::isEncryptionEnabled() const
return usesEncryption_;
}
bool
RoomSettings::supportsKnocking() const
{
return info_.version != "" && info_.version != "1" && info_.version != "2" &&
info_.version != "3" && info_.version != "4" && info_.version != "5" &&
info_.version != "6";
}
bool
RoomSettings::supportsRestricted() 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";
}
void
RoomSettings::openEditModal()
{
@ -464,6 +483,15 @@ RoomSettings::changeAccessRules(int index)
case 1:
event.join_rule = state::JoinRule::Public;
break;
case 2:
event.join_rule = state::JoinRule::Invite;
break;
case 3:
event.join_rule = state::JoinRule::Knock;
break;
case 4:
event.join_rule = state::JoinRule::Restricted;
break;
default:
event.join_rule = state::JoinRule::Invite;
}

View file

@ -78,6 +78,8 @@ class RoomSettings : public QObject
Q_PROPERTY(bool canChangeJoinRules READ canChangeJoinRules CONSTANT)
Q_PROPERTY(bool canChangeNameAndTopic READ canChangeNameAndTopic CONSTANT)
Q_PROPERTY(bool isEncryptionEnabled READ isEncryptionEnabled NOTIFY encryptionChanged)
Q_PROPERTY(bool supportsKnocking READ supportsKnocking CONSTANT)
Q_PROPERTY(bool supportsRestricted READ supportsRestricted CONSTANT)
public:
RoomSettings(QString roomid, QObject *parent = nullptr);
@ -98,6 +100,8 @@ public:
//! Whether the user has enough power level to send m.room.avatar event.
bool canChangeAvatar() const;
bool isEncryptionEnabled() const;
bool supportsKnocking() const;
bool supportsRestricted() const;
Q_INVOKABLE void enableEncryption();
Q_INVOKABLE void updateAvatar();