Improved user perms.

This commit is contained in:
Black Hat
2020-01-06 01:39:55 +08:00
parent 3544e5441f
commit d13a88a854
3 changed files with 26 additions and 15 deletions

View File

@@ -84,11 +84,11 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
auto pl = m_currentRoom->getCurrentState<RoomPowerLevelsEvent>();
auto userPl = pl->powerLevelForUser(user->id());
if (userPl == pl->content().usersDefault) {
if (userPl == pl->content().usersDefault) { // Shortcut
return UserType::Member;
}
if (userPl < pl->content().usersDefault) {
if (userPl < pl->powerLevelForState("m.room.message")) {
return UserType::Muted;
}
@@ -105,10 +105,18 @@ QVariant UserListModel::data(const QModelIndex& index, int role) const {
}
if (userPl == highestPl) {
return UserType::Owner;
}
if (userPl >= pl->powerLevelForState("m.room.power_levels")) {
return UserType::Admin;
}
return UserType::Moderator;
if (userPl >= pl->ban() || userPl >= pl->kick() || userPl >= pl->redact()) {
return UserType::Moderator;
}
return UserType::Member;
}
return {};

View File

@@ -17,7 +17,8 @@ class UserType : public QObject {
public:
enum Types {
Admin = 1,
Owner = 1,
Admin,
Moderator,
Member,
Muted,