From 856a751fcb222050455dde07634e07c0ecaf75ff Mon Sep 17 00:00:00 2001 From: James Graham Date: Tue, 14 Jan 2025 18:54:34 +0000 Subject: [PATCH] Fix Getting Member Objects It seems that there are no guarantees that we will have a room member event available when a message has arrived especially early on after room load so we should create member object unconditionally and make it the responsibility of the caller to only ask for real senders. BUG: 498649 --- src/neochatroom.cpp | 4 ---- src/neochatroom.h | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 733b0d547..876b3f919 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -1729,10 +1729,6 @@ void NeoChatRoom::setRoomState(const QString &type, const QString &stateKey, con NeochatRoomMember *NeoChatRoom::qmlSafeMember(const QString &memberId) { - if (!isMember(memberId)) { - return nullptr; - } - if (!m_memberObjects.contains(memberId)) { return m_memberObjects.emplace(memberId, std::make_unique(this, memberId)).first->second.get(); } diff --git a/src/neochatroom.h b/src/neochatroom.h index 97367f488..062f938cd 100644 --- a/src/neochatroom.h +++ b/src/neochatroom.h @@ -588,6 +588,15 @@ public: */ Quotient::FileTransferInfo cachedFileTransferInfo(const Quotient::RoomEvent *event) const; + /** + * @brief Return a NeochatRoomMember object for the given user ID. + * + * @warning Because we can't guarantee that a member state event is downloaded + * before a message they sent arrives this will create the object unconditionally + * assuming that the state event will turn up later. It is therefor the + * responsibility of the caller to ensure that they only ask for objects + * for real senders. + */ NeochatRoomMember *qmlSafeMember(const QString &memberId); /**