From 4c1a8d3657b5514529aa26a8fd7c316c12e959c1 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 16 Jul 2025 18:08:36 -0400 Subject: [PATCH] Show the user's id or a room's canonical alias (if set) in invites This should prevent the easiest way of masquerading, and provide an \ important identifier for rooms. Note that *only* the room canonical alias is shown, if it's not set then it's just the display name. This is intentional as regular users rarely interact with room IDs, but they can still check it elsewhere in NeoChat. --- src/app/qml/InvitationView.qml | 18 +++++++++++++++++- src/libneochat/neochatroom.cpp | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/app/qml/InvitationView.qml b/src/app/qml/InvitationView.qml index f1a75ef8c..aab6b12df 100644 --- a/src/app/qml/InvitationView.qml +++ b/src/app/qml/InvitationView.qml @@ -52,6 +52,15 @@ ColumnLayout { Layout.alignment: Qt.AlignHCenter } + Kirigami.SelectableLabel { + Layout.fillWidth: true + font: Kirigami.Theme.smallFont + textFormat: TextEdit.PlainText + visible: root.currentRoom && root.currentRoom.canonicalAlias + text: root.currentRoom && root.currentRoom.canonicalAlias ? root.currentRoom.canonicalAlias : "" + color: Kirigami.Theme.disabledTextColor + } + Kirigami.Heading { text: root.currentRoom.displayName @@ -70,7 +79,14 @@ ColumnLayout { spacing: Kirigami.Units.smallSpacing Kirigami.Heading { - text: root.currentRoom.displayName + text: root.invitingMember.displayName + + Layout.alignment: Qt.AlignHCenter + } + + QQC2.Label { + text: root.invitingMember.id + color: Kirigami.Theme.disabledTextColor Layout.alignment: Qt.AlignHCenter } diff --git a/src/libneochat/neochatroom.cpp b/src/libneochat/neochatroom.cpp index a605edd42..7b7a58b13 100644 --- a/src/libneochat/neochatroom.cpp +++ b/src/libneochat/neochatroom.cpp @@ -1674,6 +1674,10 @@ void NeoChatRoom::setRoomState(const QString &type, const QString &stateKey, con NeochatRoomMember *NeoChatRoom::qmlSafeMember(const QString &memberId) { + if (memberId.isEmpty()) { + return nullptr; + } + if (!m_memberObjects.contains(memberId)) { auto member = m_memberObjects.emplace(memberId, std::make_unique(this, memberId)).first->second.get(); QQmlEngine::setObjectOwnership(member, QQmlEngine::CppOwnership);