[network/neochat] src/libneochat: Wait until encryption is set up before decrypting pinned message

Joshua Goins <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 27334d921b8327fc03d3250e2d2ae458e572125b by Joshua Goins.
Committed on 18/07/2026 at 14:16.
Pushed by redstrate into branch 'master'.

Wait until encryption is set up before decrypting pinned message

See https://github.com/quotient-im/libQuotient/pull/977 for the crash
related to this issue.

M  +8    -2    src/libneochat/neochatroom.cpp

https://invent.kde.org/network/neochat/-/commit/27334d921b8327fc03d3250e2d2ae458e572125b

diff --git a/src/libneochat/neochatroom.cpp b/src/libneochat/neochatroom.cpp
index 5c4f5e9b2..3061cceea 100644
--- a/src/libneochat/neochatroom.cpp
+++ b/src/libneochat/neochatroom.cpp
@@ -131,9 +131,15 @@ NeoChatRoom::NeoChatRoom(Connection *c, QString roomId, JoinState joinState)
         this,
         &Room::baseStateLoaded,
         this,
-        [this]() {
+        [this, connection] {
             updatePushNotificationState(u"m.push_rules"_s);
-            loadPinnedMessage();
+
+            // We need to wait until encryption is set up, otherwise the event isn't decrypted.
+            if (!connection->encryptionEnabled()) {
+                connect(connection, &Connection::ready, this, &NeoChatRoom::loadPinnedMessage, Qt::SingleShotConnection);
+            } else {
+                loadPinnedMessage();
+            }
 
             Q_EMIT canEncryptRoomChanged();
             Q_EMIT inviteTimestampChanged();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.