Add backend for new room creation dialogs

This commit is contained in:
Nicolas Werner 2022-03-29 04:50:25 +02:00
parent d7cb2bd647
commit 6d1416fb6e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
14 changed files with 125 additions and 275 deletions

View file

@ -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;