diff --git a/src/libneochat/models/userlistmodel.cpp b/src/libneochat/models/userlistmodel.cpp index 63caf072c..f530e30cb 100644 --- a/src/libneochat/models/userlistmodel.cpp +++ b/src/libneochat/models/userlistmodel.cpp @@ -100,6 +100,10 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const return plEvent->powerLevelForUser(memberId); } if (role == PowerLevelStringRole) { + if (m_currentRoom->roomCreatorHasUltimatePowerLevel() && m_currentRoom->isCreator(memberId)) { + return i18nc("@info the person that created this room", "Creator"); + } + auto pl = m_currentRoom->currentState().get(); // User might not in the room yet, in this case pl can be nullptr. // e.g. When invited but user not accepted or denied the invitation. diff --git a/src/libneochat/neochatroom.cpp b/src/libneochat/neochatroom.cpp index 7b7a58b13..8a857f3ad 100644 --- a/src/libneochat/neochatroom.cpp +++ b/src/libneochat/neochatroom.cpp @@ -536,6 +536,9 @@ bool NeoChatRoom::containsUser(const QString &userID) const bool NeoChatRoom::canSendEvent(const QString &eventType) const { + if (roomCreatorHasUltimatePowerLevel() && isCreator(localMember().id())) { + return true; + } auto plEvent = currentState().get(); if (!plEvent) { return false; @@ -548,6 +551,9 @@ bool NeoChatRoom::canSendEvent(const QString &eventType) const bool NeoChatRoom::canSendState(const QString &eventType) const { + if (roomCreatorHasUltimatePowerLevel() && isCreator(localMember().id())) { + return true; + } auto plEvent = currentState().get(); if (!plEvent) { return false; @@ -1741,4 +1747,20 @@ void NeoChatRoom::setHiddenFilter(std::functionversion().toInt(&ok); + // This is terrible. For non-numeric room versions, I don't think there's a way of knowing whether they're pre- or post hydra. + // We just assume they are. Shouldn't matter for normal users anyway. + return !ok || version > 11; +} + +bool NeoChatRoom::isCreator(const QString &userId) const +{ + auto createEvent = currentState().get(); + return roomCreatorHasUltimatePowerLevel() && createEvent + && (createEvent->senderId() == userId || createEvent->contentPart(u"additional_creators"_s).contains(userId)); +} + #include "moc_neochatroom.cpp" diff --git a/src/libneochat/neochatroom.h b/src/libneochat/neochatroom.h index f18553b5d..5bd789ef6 100644 --- a/src/libneochat/neochatroom.h +++ b/src/libneochat/neochatroom.h @@ -589,6 +589,18 @@ public: static void setHiddenFilter(std::function hiddenFilter); + /** + * @brief Whether this room has a room version where the creator is treated as having an ultimate power level + * + * For unusual room versions, this information might be wrong. + */ + bool roomCreatorHasUltimatePowerLevel() const; + + /** + * @brief Whether this user is considered a creator of this room. Only applies to post-v12 rooms. + */ + bool isCreator(const QString &userId) const; + private: bool m_visible = false;