From ef941920eaafe0449b01d344c631efe4c017cbad Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Fri, 17 Jun 2022 03:11:31 +0200 Subject: [PATCH] Fix compilation without implicit nlohmann conversions --- CMakeLists.txt | 2 +- io.github.NhekoReborn.Nheko.yaml | 2 +- src/Cache.cpp | 114 ++++++++++++---------- src/ChatPage.cpp | 3 +- src/Logging.h | 2 +- src/encryption/DeviceVerificationFlow.cpp | 8 +- src/encryption/Olm.cpp | 21 ++-- src/timeline/TimelineModel.h | 2 +- src/ui/UIA.cpp | 1 + src/ui/UIA.h | 2 +- 10 files changed, 86 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6af90d6..fa8c6ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -576,7 +576,7 @@ if(USE_BUNDLED_MTXCLIENT) FetchContent_Declare( MatrixClient GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git - GIT_TAG a6ca9714490ad0bb0c032e00be4f7d7ebd683378 + GIT_TAG e13a71d3ca883e8ed88e0b60adb0914120328bac ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 3d488000..91fb1a08 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -203,7 +203,7 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: a6ca9714490ad0bb0c032e00be4f7d7ebd683378 + - commit: e13a71d3ca883e8ed88e0b60adb0914120328bac #tag: v0.7.0 type: git url: https://github.com/Nheko-Reborn/mtxclient.git diff --git a/src/Cache.cpp b/src/Cache.cpp index 756e50ad..b2027114 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -561,7 +561,7 @@ Cache::roomEncryptionSettings(const std::string &room_id) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = json::parse(event).get>(); return msg.content; } catch (const json::exception &e) { @@ -810,7 +810,8 @@ Cache::getOutboundMegolmSession(const std::string &room_id) auto obj = json::parse(value); OutboundGroupSessionDataRef ref{}; - ref.session = unpickle(obj.at("session"), pickle_secret_); + ref.session = + unpickle(obj.at("session").get(), pickle_secret_); MegolmSessionIndex index; index.room_id = room_id; @@ -1155,7 +1156,7 @@ Cache::runMigrations() if (oldMessages.prev_batch.empty()) oldMessages.prev_batch = j["token"].get(); - else if (j["token"] != oldMessages.prev_batch) + else if (j["token"].get() != oldMessages.prev_batch) break; mtx::events::collections::TimelineEvent te; @@ -1325,7 +1326,7 @@ Cache::runMigrations() std::map megolmSessionData; while (cursor.get(key, value, MDB_NEXT)) { auto indexVal = nlohmann::json::parse(key); - auto sender_key = indexVal["sender_key"]; + auto sender_key = indexVal["sender_key"].get(); indexVal.erase("sender_key"); std::string_view dataVal; @@ -1549,7 +1550,8 @@ Cache::updateState(const std::string &room, const mtx::responses::StateEvents &s std::string_view data; if (roomsDb_.get(txn, room, data)) { try { - updatedInfo = json::parse(std::string_view(data.data(), data.size())); + updatedInfo = + json::parse(std::string_view(data.data(), data.size())).get(); } catch (const json::exception &e) { nhlog::db()->warn("failed to parse room info: room_id ({}), {}: {}", room, @@ -1669,7 +1671,8 @@ Cache::saveState(const mtx::responses::Sync &res) std::string_view data; if (roomsDb_.get(txn, room.first, data)) { try { - RoomInfo tmp = json::parse(std::string_view(data.data(), data.size())); + RoomInfo tmp = + json::parse(std::string_view(data.data(), data.size())).get(); updatedInfo.tags = std::move(tmp.tags); updatedInfo.approximate_last_modification_ts = @@ -1954,7 +1957,7 @@ Cache::singleRoomInfo(const std::string &room_id) // Check if the room is joined. if (roomsDb_.get(txn, room_id, data)) { try { - RoomInfo tmp = json::parse(data); + RoomInfo tmp = json::parse(data).get(); tmp.member_count = getMembersDb(txn, room_id).size(txn); tmp.join_rule = getRoomJoinRule(txn, statesdb); tmp.guest_access = getRoomGuestAccess(txn, statesdb); @@ -1989,7 +1992,7 @@ Cache::getRoomInfo(const std::vector &rooms) // Check if the room is joined. if (roomsDb_.get(txn, room, data)) { try { - RoomInfo tmp = json::parse(data); + RoomInfo tmp = json::parse(data).get(); tmp.member_count = getMembersDb(txn, room).size(txn); tmp.join_rule = getRoomJoinRule(txn, statesdb); tmp.guest_access = getRoomGuestAccess(txn, statesdb); @@ -2005,7 +2008,7 @@ Cache::getRoomInfo(const std::vector &rooms) // Check if the room is an invite. if (invitesDb_.get(txn, room, data)) { try { - RoomInfo tmp = json::parse(std::string_view(data)); + RoomInfo tmp = json::parse(std::string_view(data)).get(); tmp.member_count = getInviteMembersDb(txn, room).size(txn); room_info.emplace(QString::fromStdString(room), std::move(tmp)); @@ -2241,7 +2244,7 @@ Cache::roomInfo(bool withInvites) // Gather info about the joined rooms. auto roomsCursor = lmdb::cursor::open(txn, roomsDb_); while (roomsCursor.get(room_id, room_data, MDB_NEXT)) { - RoomInfo tmp = json::parse(std::move(room_data)); + RoomInfo tmp = json::parse(std::move(room_data)).get(); tmp.member_count = getMembersDb(txn, std::string(room_id)).size(txn); result.insert(QString::fromStdString(std::string(room_id)), std::move(tmp)); } @@ -2251,7 +2254,7 @@ Cache::roomInfo(bool withInvites) // Gather info about the invites. auto invitesCursor = lmdb::cursor::open(txn, invitesDb_); while (invitesCursor.get(room_id, room_data, MDB_NEXT)) { - RoomInfo tmp = json::parse(room_data); + RoomInfo tmp = json::parse(room_data).get(); tmp.member_count = getInviteMembersDb(txn, std::string(room_id)).size(txn); result.insert(QString::fromStdString(std::string(room_id)), std::move(tmp)); } @@ -2478,7 +2481,7 @@ Cache::invites() while (cursor.get(room_id, room_data, MDB_NEXT)) { try { - RoomInfo tmp = json::parse(room_data); + RoomInfo tmp = json::parse(room_data).get(); tmp.member_count = getInviteMembersDb(txn, std::string(room_id)).size(txn); result.insert(QString::fromStdString(std::string(room_id)), std::move(tmp)); } catch (const json::exception &e) { @@ -2506,7 +2509,7 @@ Cache::invite(std::string_view roomid) if (invitesDb_.get(txn, roomid, room_data)) { try { - RoomInfo tmp = json::parse(room_data); + RoomInfo tmp = json::parse(room_data).get(); tmp.member_count = getInviteMembersDb(txn, std::string(roomid)).size(txn); result = std::move(tmp); } catch (const json::exception &e) { @@ -2532,7 +2535,8 @@ Cache::getRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersd if (res) { try { - StateEvent msg = json::parse(std::string_view(event.data(), event.size())); + StateEvent msg = + json::parse(std::string_view(event.data(), event.size())).get>(); if (!msg.content.url.empty()) return QString::fromStdString(msg.content.url); @@ -2553,7 +2557,7 @@ Cache::getRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersd // Resolve avatar for 1-1 chats. while (cursor.get(user_id, member_data, MDB_NEXT)) { try { - MemberInfo m = json::parse(member_data); + MemberInfo m = json::parse(member_data).get(); if (user_id == localUserId_.toStdString()) { fallback_url = m.avatar_url; continue; @@ -2583,7 +2587,8 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) if (res) { try { - StateEvent msg = json::parse(std::string_view(event.data(), event.size())); + StateEvent msg = + json::parse(std::string_view(event.data(), event.size())).get>(); if (!msg.content.name.empty()) return QString::fromStdString(msg.content.name); @@ -2597,7 +2602,8 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) if (res) { try { StateEvent msg = - json::parse(std::string_view(event.data(), event.size())); + json::parse(std::string_view(event.data(), event.size())) + .get>(); if (!msg.content.alias.empty()) return QString::fromStdString(msg.content.alias); @@ -2616,7 +2622,7 @@ Cache::getRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &membersdb) while (cursor.get(user_id, member_data, MDB_NEXT) && ii < 3) { try { - members.emplace(user_id, json::parse(member_data)); + members.emplace(user_id, json::parse(member_data).get()); } catch (const json::exception &e) { nhlog::db()->warn("failed to parse member info: {}", e.what()); } @@ -2657,7 +2663,8 @@ Cache::getRoomJoinRule(lmdb::txn &txn, lmdb::dbi &statesdb) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = + json::parse(event).get>(); return msg.content.join_rule; } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.join_rule event: {}", e.what()); @@ -2677,7 +2684,7 @@ Cache::getRoomGuestAccess(lmdb::txn &txn, lmdb::dbi &statesdb) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = json::parse(event).get>(); return msg.content.guest_access == AccessState::CanJoin; } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.guest_access event: {}", e.what()); @@ -2697,7 +2704,7 @@ Cache::getRoomTopic(lmdb::txn &txn, lmdb::dbi &statesdb) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = json::parse(event).get>(); if (!msg.content.topic.empty()) return QString::fromStdString(msg.content.topic); @@ -2720,7 +2727,7 @@ Cache::getRoomVersion(lmdb::txn &txn, lmdb::dbi &statesdb) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = json::parse(event).get>(); if (!msg.content.room_version.empty()) return QString::fromStdString(msg.content.room_version); @@ -2744,7 +2751,7 @@ Cache::getRoomIsSpace(lmdb::txn &txn, lmdb::dbi &statesdb) if (res) { try { - StateEvent msg = json::parse(event); + StateEvent msg = json::parse(event).get>(); return msg.content.type == mtx::events::state::room_type::space; } catch (const json::exception &e) { @@ -2767,7 +2774,7 @@ Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &members if (res) { try { - StrippedEvent msg = json::parse(event); + StrippedEvent msg = json::parse(event).get>(); return QString::fromStdString(msg.content.name); } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.name event: {}", e.what()); @@ -2782,7 +2789,7 @@ Cache::getInviteRoomName(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &members continue; try { - MemberInfo tmp = json::parse(member_data); + MemberInfo tmp = json::parse(member_data).get(); cursor.close(); return QString::fromStdString(tmp.name); @@ -2807,7 +2814,8 @@ Cache::getInviteRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &me if (res) { try { - StrippedEvent msg = json::parse(event); + StrippedEvent msg = + json::parse(event).get>(); return QString::fromStdString(msg.content.url); } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.avatar event: {}", e.what()); @@ -2822,7 +2830,7 @@ Cache::getInviteRoomAvatarUrl(lmdb::txn &txn, lmdb::dbi &statesdb, lmdb::dbi &me continue; try { - MemberInfo tmp = json::parse(member_data); + MemberInfo tmp = json::parse(member_data).get(); cursor.close(); return QString::fromStdString(tmp.avatar_url); @@ -2847,7 +2855,7 @@ Cache::getInviteRoomTopic(lmdb::txn &txn, lmdb::dbi &db) if (res) { try { - StrippedEvent msg = json::parse(event); + StrippedEvent msg = json::parse(event).get>(); return QString::fromStdString(msg.content.topic); } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.topic event: {}", e.what()); @@ -2868,7 +2876,7 @@ Cache::getInviteRoomIsSpace(lmdb::txn &txn, lmdb::dbi &db) if (res) { try { - StrippedEvent msg = json::parse(event); + StrippedEvent msg = json::parse(event).get>(); return msg.content.type == mtx::events::state::room_type::space; } catch (const json::exception &e) { nhlog::db()->warn("failed to parse m.room.topic event: {}", e.what()); @@ -2909,7 +2917,7 @@ Cache::getMember(const std::string &room_id, const std::string &user_id) std::string_view info; if (membersdb.get(txn, user_id, info)) { - MemberInfo m = json::parse(info); + MemberInfo m = json::parse(info).get(); return m; } } catch (std::exception &e) { @@ -2943,7 +2951,7 @@ Cache::getMembers(const std::string &room_id, std::size_t startIndex, std::size_ break; try { - MemberInfo tmp = json::parse(user_data); + MemberInfo tmp = json::parse(user_data).get(); members.emplace_back(RoomMember{QString::fromStdString(std::string(user_id)), QString::fromStdString(tmp.name)}); } catch (const json::exception &e) { @@ -2983,7 +2991,7 @@ Cache::getMembersFromInvite(const std::string &room_id, std::size_t startIndex, break; try { - MemberInfo tmp = json::parse(user_data); + MemberInfo tmp = json::parse(user_data).get(); members.emplace_back(RoomMember{QString::fromStdString(std::string(user_id)), QString::fromStdString(tmp.name), tmp.is_direct}); @@ -3745,7 +3753,7 @@ Cache::spaces() if (!space_child.empty()) { std::string_view room_data; if (roomsDb_.get(txn, space_id, room_data)) { - RoomInfo tmp = json::parse(std::move(room_data)); + RoomInfo tmp = json::parse(std::move(room_data)).get(); ret.insert(QString::fromUtf8(space_id.data(), space_id.size()), tmp); } else { ret.insert(QString::fromUtf8(space_id.data(), space_id.size()), std::nullopt); @@ -3926,7 +3934,8 @@ Cache::hasEnoughPowerLevel(const std::vector &eventTypes if (res) { try { - StateEvent msg = json::parse(std::string_view(event.data(), event.size())); + StateEvent msg = json::parse(std::string_view(event.data(), event.size())) + .get>(); user_level = msg.content.user_level(user_id); @@ -4121,7 +4130,8 @@ Cache::presence(const std::string &user_id) auto res = presenceDb_.get(txn, user_id, presenceVal); if (res) { - presence_ = json::parse(std::string_view(presenceVal.data(), presenceVal.size())); + presence_ = json::parse(std::string_view(presenceVal.data(), presenceVal.size())) + .get(); } return presence_; @@ -4484,7 +4494,7 @@ Cache::verificationCache(const std::string &user_id, lmdb::txn &txn) VerificationCache verified_state; auto res = db.get(txn, user_id, verifiedVal); if (res) { - verified_state = json::parse(verifiedVal); + verified_state = json::parse(verifiedVal).get(); return verified_state; } else { return {}; @@ -4507,7 +4517,7 @@ Cache::markDeviceVerified(const std::string &user_id, const std::string &key) VerificationCache verified_state; auto res = db.get(txn, user_id, val); if (res) { - verified_state = json::parse(val); + verified_state = json::parse(val).get(); } for (const auto &device : verified_state.device_verified) @@ -4554,7 +4564,7 @@ Cache::markDeviceUnverified(const std::string &user_id, const std::string &key) VerificationCache verified_state; auto res = db.get(txn, user_id, val); if (res) { - verified_state = json::parse(val); + verified_state = json::parse(val).get(); } verified_state.device_verified.erase(key); @@ -4751,15 +4761,15 @@ to_json(json &j, const RoomInfo &info) void from_json(const json &j, RoomInfo &info) { - info.name = j.at("name"); - info.topic = j.at("topic"); - info.avatar_url = j.at("avatar_url"); + info.name = j.at("name").get(); + info.topic = j.at("topic").get(); + info.avatar_url = j.at("avatar_url").get(); info.version = j.value( "version", QCoreApplication::translate("RoomInfo", "no version stored").toStdString()); - info.is_invite = j.at("is_invite"); + info.is_invite = j.at("is_invite").get(); info.is_space = j.value("is_space", false); - info.join_rule = j.at("join_rule"); - info.guest_access = j.at("guest_access"); + info.join_rule = j.at("join_rule").get(); + info.guest_access = j.at("guest_access").get(); info.approximate_last_modification_ts = j.value("app_l_ts", 0); @@ -4767,7 +4777,7 @@ from_json(const json &j, RoomInfo &info) info.highlight_count = j.value("highlight_count", 0); if (j.count("member_count")) - info.member_count = j.at("member_count"); + info.member_count = j.at("member_count").get(); if (j.count("tags")) info.tags = j.at("tags").get>(); @@ -4798,8 +4808,8 @@ to_json(json &j, const MemberInfo &info) void from_json(const json &j, MemberInfo &info) { - info.name = j.at("name"); - info.avatar_url = j.at("avatar_url"); + info.name = j.at("name").get(); + info.avatar_url = j.at("avatar_url").get(); info.is_direct = j.value("is_direct", false); } @@ -4846,7 +4856,7 @@ to_json(nlohmann::json &obj, const GroupSessionData &msg) void from_json(const nlohmann::json &obj, GroupSessionData &msg) { - msg.message_index = obj.at("message_index"); + msg.message_index = obj.at("message_index").get(); msg.timestamp = obj.value("ts", 0ULL); msg.trusted = obj.value("trust", true); @@ -4870,8 +4880,8 @@ to_json(nlohmann::json &obj, const DevicePublicKeys &msg) void from_json(const nlohmann::json &obj, DevicePublicKeys &msg) { - msg.ed25519 = obj.at("ed25519"); - msg.curve25519 = obj.at("curve25519"); + msg.ed25519 = obj.at("ed25519").get(); + msg.curve25519 = obj.at("curve25519").get(); } void @@ -4884,8 +4894,8 @@ to_json(nlohmann::json &obj, const MegolmSessionIndex &msg) void from_json(const nlohmann::json &obj, MegolmSessionIndex &msg) { - msg.room_id = obj.at("room_id"); - msg.session_id = obj.at("session_id"); + msg.room_id = obj.at("room_id").get(); + msg.session_id = obj.at("session_id").get(); } void diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index d42d0a61..38d2c8e9 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -1257,7 +1257,8 @@ ChatPage::decryptDownloadedSecrets(mtx::secret_storage::AesHmacSha2KeyDescriptio json j = deviceKeys->master_keys; j.erase("signatures"); j.erase("unsigned"); - mtx::crypto::CrossSigningKeys master_key = j; + mtx::crypto::CrossSigningKeys master_key = + j.get(); master_key.signatures[http::client()->user_id().to_string()] ["ed25519:" + http::client()->device_id()] = olm::client()->sign_message(j.dump()); diff --git a/src/Logging.h b/src/Logging.h index 3676af01..4a5109a6 100644 --- a/src/Logging.h +++ b/src/Logging.h @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace nhlog { void diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index cc12bb9b..098347cd 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -270,7 +270,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, json j = their_keys.master_keys; j.erase("signatures"); j.erase("unsigned"); - mtx::crypto::CrossSigningKeys master_key = j; + mtx::crypto::CrossSigningKeys master_key = + j.get(); master_key.signatures[utils::localUser().toStdString()] ["ed25519:" + http::client()->device_id()] = olm::client()->sign_message(j.dump()); @@ -292,7 +293,7 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, continue; auto ssk = mtx::crypto::PkSigning::from_seed(*secret); - mtx::crypto::DeviceKeys dev = j; + mtx::crypto::DeviceKeys dev = j.get(); dev.signatures[utils::localUser().toStdString()] ["ed25519:" + ssk.public_key()] = ssk.sign(j.dump()); @@ -314,7 +315,8 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, continue; auto usk = mtx::crypto::PkSigning::from_seed(*secret); - mtx::crypto::CrossSigningKeys master_key = j; + mtx::crypto::CrossSigningKeys master_key = + j.get(); master_key.signatures[utils::localUser().toStdString()] ["ed25519:" + usk.public_key()] = usk.sign(j.dump()); diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index 4747a7e9..5387d215 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -47,8 +47,8 @@ from_json(const nlohmann::json &obj, OlmMessage &msg) if (obj.at("content").at("algorithm") != OLM_ALGO) throw std::invalid_argument("invalid algorithm for olm message"); - msg.sender = obj.at("sender"); - msg.sender_key = obj.at("content").at("sender_key"); + msg.sender = obj.at("sender").get(); + msg.sender_key = obj.at("content").at("sender_key").get(); msg.ciphertext = obj.at("content") .at("ciphertext") .get>(); @@ -122,11 +122,11 @@ handle_to_device_messages(const std::vector(); if (msg_type == to_string(mtx::events::EventType::RoomEncrypted)) { try { - olm::OlmMessage olm_msg = j_msg; + olm::OlmMessage olm_msg = j_msg.get(); cache::client()->query_keys( olm_msg.sender, [olm_msg](const UserKeyCache &userKeys, mtx::http::RequestErr e) { if (e) { @@ -147,7 +147,8 @@ handle_to_device_messages(const std::vectorwarn("handling key request event: {}", j_msg.dump(2)); try { - mtx::events::DeviceEvent req = j_msg; + mtx::events::DeviceEvent req = + j_msg.get>(); if (req.content.action == mtx::events::msg::RequestAction::Request) handle_key_request_message(req); else @@ -246,14 +247,14 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey // claiming to have sent messages which they didn't. sender must correspond // to the user who sent the event, recipient to the local user, and // recipient_keys to the local ed25519 key. - std::string receiver_ed25519 = payload["recipient_keys"]["ed25519"]; + std::string receiver_ed25519 = payload["recipient_keys"]["ed25519"].get(); if (receiver_ed25519.empty() || receiver_ed25519 != olm::client()->identity_keys().ed25519) { nhlog::crypto()->warn("Decrypted event doesn't include our ed25519: {}", payload.dump()); return; } - std::string receiver = payload["recipient"]; + std::string receiver = payload["recipient"].get(); if (receiver.empty() || receiver != http::client()->user_id().to_string()) { nhlog::crypto()->warn("Decrypted event doesn't include our user_id: {}", payload.dump()); @@ -266,7 +267,7 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey // this check, a client cannot be sure that the sender device owns the // private part of the ed25519 key it claims to have in the Olm payload. // This is crucial when the ed25519 key corresponds to a verified device. - std::string sender_ed25519 = payload["keys"]["ed25519"]; + std::string sender_ed25519 = payload["keys"]["ed25519"].get(); if (sender_ed25519.empty()) { nhlog::crypto()->warn("Decrypted event doesn't include sender ed25519: {}", payload.dump()); @@ -294,7 +295,7 @@ handle_olm_message(const OlmMessage &msg, const UserKeyCache &otherUserDeviceKey } { - std::string msg_type = payload["type"]; + std::string msg_type = payload["type"].get(); json event_array = json::array(); event_array.push_back(payload); @@ -1334,7 +1335,7 @@ send_encrypted_to_device_messages(const std::mapat("key"); + auto otk = rd.second.begin()->at("key").get(); auto sign_key = pks.at(user_id).at(device_id).ed25519; auto id_key = pks.at(user_id).at(device_id).curve25519; diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index ec9a34f1..7b5fb907 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -464,7 +464,7 @@ private: friend struct SendMessageVisitor; - int notification_count = 0, highlight_count = 0; + uint64_t notification_count = 0, highlight_count = 0; unsigned int relatedEventCacheBuster = 0; diff --git a/src/ui/UIA.cpp b/src/ui/UIA.cpp index 7c6e440c..93fd6c94 100644 --- a/src/ui/UIA.cpp +++ b/src/ui/UIA.cpp @@ -13,6 +13,7 @@ #include #include "Logging.h" +#include "MatrixClient.h" #include "dialogs/FallbackAuth.h" #include "dialogs/ReCaptcha.h" diff --git a/src/ui/UIA.h b/src/ui/UIA.h index 150b595d..c7c88675 100644 --- a/src/ui/UIA.h +++ b/src/ui/UIA.h @@ -7,7 +7,7 @@ #include -#include +#include class UIA : public QObject {