From 8cdfbf9391be01be8e52c7747482b336cefdfb27 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 17 Jun 2022 22:03:54 +0200 Subject: Get rid of 'using json = nlohmann::json' --- src/encryption/DeviceVerificationFlow.cpp | 6 +++--- src/encryption/Olm.cpp | 22 +++++++++++----------- src/encryption/SelfVerificationStatus.cpp | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'src/encryption') diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index 098347cd..fa06fba2 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -267,7 +267,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, // verified it for (const auto &mac : msg.mac) { if (their_keys.master_keys.keys.count(mac.first)) { - json j = their_keys.master_keys; + nlohmann::json j = their_keys.master_keys; j.erase("signatures"); j.erase("unsigned"); mtx::crypto::CrossSigningKeys master_key = @@ -283,7 +283,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, auto device_id = this->deviceId.toStdString(); if (their_keys.device_keys.count(device_id)) { - json j = their_keys.device_keys.at(device_id); + nlohmann::json j = their_keys.device_keys.at(device_id); j.erase("signatures"); j.erase("unsigned"); @@ -305,7 +305,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, // Sign their master key with user signing key for (const auto &mac : msg.mac) { if (their_keys.master_keys.keys.count(mac.first)) { - json j = their_keys.master_keys; + nlohmann::json j = their_keys.master_keys; j.erase("signatures"); j.erase("unsigned"); diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index 5387d215..8bf2222f 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -116,7 +116,7 @@ handle_to_device_messages(const std::vectorwarn("received message with no type field: {}", j_msg.dump(2)); continue; @@ -295,8 +295,8 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey } { - std::string msg_type = payload["type"].get(); - json event_array = json::array(); + std::string msg_type = payload["type"].get(); + nlohmann::json event_array = nlohmann::json::array(); event_array.push_back(payload); std::vector temp_events; @@ -456,7 +456,7 @@ handle_pre_key_olm_message(const std::string &sender, return {}; } - auto plaintext = json::parse(std::string((char *)output.data(), output.size())); + auto plaintext = nlohmann::json::parse(std::string((char *)output.data(), output.size())); nhlog::crypto()->debug("decrypted message: \n {}", plaintext.dump(2)); try { @@ -716,8 +716,8 @@ try_olm_decryption(const std::string &sender_key, const mtx::events::msg::OlmCip } try { - return json::parse(std::string_view((char *)text.data(), text.size())); - } catch (const json::exception &e) { + return nlohmann::json::parse(std::string_view((char *)text.data(), text.size())); + } catch (const nlohmann::json::exception &e) { nhlog::crypto()->critical("failed to parse the decrypted session msg: {} {}", e.what(), std::string_view((char *)text.data(), text.size())); @@ -980,7 +980,7 @@ send_key_request_for(mtx::events::EncryptedEvent e, request.request_id = request_id; request.requesting_device_id = http::client()->device_id(); - nhlog::crypto()->debug("m.room_key_request: {}", json(request).dump(2)); + nhlog::crypto()->debug("m.room_key_request: {}", nlohmann::json(request).dump(2)); std::map> body; body[mtx::identifiers::parse(e.sender)]["*"] = request; @@ -1171,7 +1171,7 @@ decryptEvent(const MegolmSessionIndex &index, try { // Add missing fields for the event. - json body = json::parse(msg_str); + nlohmann::json body = nlohmann::json::parse(msg_str); body["event_id"] = event.event_id; body["sender"] = event.sender; body["origin_server_ts"] = event.origin_server_ts; @@ -1212,7 +1212,7 @@ send_encrypted_to_device_messages(const std::map, qint64> rateLimit; - nlohmann::json ev_json = std::visit([](const auto &e) { return json(e); }, event); + nlohmann::json ev_json = std::visit([](const auto &e) { return nlohmann::json(e); }, event); std::map> keysToQuery; mtx::requests::ClaimKeys claims; @@ -1450,10 +1450,10 @@ send_encrypted_to_device_messages(const std::mapwarn("failed to verify identity keys: {}", - json(dev.second).dump(2)); + nlohmann::json(dev.second).dump(2)); continue; } - } catch (const json::exception &e) { + } catch (const nlohmann::json::exception &e) { nhlog::crypto()->warn("failed to parse device key json: {}", e.what()); continue; } catch (const mtx::crypto::olm_exception &e) { diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp index ab50b6f3..f37b2af4 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp @@ -152,7 +152,7 @@ SelfVerificationStatus::setupCrosssigning(bool useSSSS, QString password, bool u olm::client()->identity_keys().ed25519 && myKey.keys["curve25519:" + http::client()->device_id()] == olm::client()->identity_keys().curve25519) { - json j = myKey; + nlohmann::json j = myKey; j.erase("signatures"); j.erase("unsigned"); -- cgit 1.5.1