From 813a8003c68fe2238236f7c5e9766efcc7a7440d Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 23 Oct 2022 22:11:35 +0200 Subject: [PATCH] Fix notifications for encrypted events BUG: 459935 --- src/controller.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/controller.cpp b/src/controller.cpp index dc6cf1868..26c170bf2 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -174,6 +174,16 @@ void Controller::handleNotifications() // The room might have been deleted (for example rejected invitation). auto sender = room->user(notification["event"].toObject()["sender"].toString()); + auto body = notification["event"].toObject()["content"].toObject()["body"].toString(); + + if (notification["event"]["type"] == "m.room.encrypted") { + auto decrypted = m_connection->decryptNotification(notification); + body = decrypted["content"].toObject()["body"].toString(); + if (body.isEmpty()) { + body = i18n("Encrypted Message"); + } + } + QImage avatar_image; if (!sender->avatarUrl(room).isEmpty()) { avatar_image = sender->avatar(128, room); @@ -182,7 +192,7 @@ void Controller::handleNotifications() } NotificationsManager::instance().postNotification(dynamic_cast(room), sender->displayname(room), - notification["event"].toObject()["content"].toObject()["body"].toString(), + body, avatar_image, notification["event"].toObject()["event_id"].toString(), true);