summaryrefslogtreecommitdiffstats
path: root/src/ChatPage.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-29 04:50:25 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-29 20:51:18 +0200
commit6d1416fb6ec7e64a765af652ea3b21722ec12be3 (patch)
treee5a7f21a13cb9aa7e4a737dd52c243da78622300 /src/ChatPage.cpp
parentd7cb2bd64734adb6938b85ac28075c2c8e8d25e0 (diff)
Add backend for new room creation dialogs
Diffstat (limited to 'src/ChatPage.cpp')
-rw-r--r--src/ChatPage.cpp10
1 files changed, 9 insertions, 1 deletions
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<bool> 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<mtx::events::state::Encryption> 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;