From 6d1416fb6ec7e64a765af652ea3b21722ec12be3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 29 Mar 2022 04:50:25 +0200 Subject: Add backend for new room creation dialogs --- src/ChatPage.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ChatPage.cpp') diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 3743eae0..a355a5b2 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -1187,7 +1187,7 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio } void -ChatPage::startChat(QString userid) +ChatPage::startChat(QString userid, std::optional encryptionEnabled) { auto joined_rooms = cache::joinedRooms(); auto room_infos = cache::getRoomInfo(joined_rooms); @@ -1213,6 +1213,14 @@ ChatPage::startChat(QString userid) mtx::requests::CreateRoom req; req.preset = mtx::requests::Preset::PrivateChat; req.visibility = mtx::common::RoomVisibility::Private; + + if (encryptionEnabled.value_or(false)) { + mtx::events::StrippedEvent enc; + enc.type = mtx::events::EventType::RoomEncryption; + enc.content.algorithm = mtx::crypto::MEGOLM_ALGO; + req.initial_state.emplace_back(std::move(enc)); + } + if (utils::localUser() != userid) { req.invite = {userid.toStdString()}; req.is_direct = true; -- cgit 1.5.1