From 3c25162ba1ffa03583059ef374590fdb1ede2203 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 2 Aug 2023 20:18:20 +0200 Subject: [PATCH] fix tox clients reconnecting --- solanaceae/tox_contacts/tox_contact_model2.cpp | 11 +++++++++-- solanaceae/tox_messages/tox_message_manager.cpp | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/solanaceae/tox_contacts/tox_contact_model2.cpp b/solanaceae/tox_contacts/tox_contact_model2.cpp index 1653f4d..89ee4c9 100644 --- a/solanaceae/tox_contacts/tox_contact_model2.cpp +++ b/solanaceae/tox_contacts/tox_contact_model2.cpp @@ -118,6 +118,9 @@ Contact3Handle ToxContactModel2::getContactFriend(uint32_t friend_number) { } if (_cr.valid(c)) { + // param friend number matches pubkey in db, add + _cr.emplace_or_replace(c, friend_number); + return {_cr, c}; } @@ -167,6 +170,9 @@ Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) { } if (_cr.valid(c)) { + // param group number matches pubkey in db, add + _cr.emplace_or_replace(c, group_number); + return {_cr, c}; } @@ -224,8 +230,6 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint // else check by key auto [g_p_key_opt, _] = _t.toxGroupPeerGetPublicKey(group_number, peer_number); - if (!g_p_key_opt.has_value()) { - } //assert(g_p_key_opt.has_value()); // TODO: handle gracefully? if (!g_p_key_opt.has_value()) { // if the key could not be retreived, that means the peer has exited (idk why the earlier search did not work, it should have) @@ -245,6 +249,9 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint } if (_cr.valid(c)) { + // param numbers matches pubkey in db, add + _cr.emplace_or_replace(c, group_number, peer_number); + return {_cr, c}; } diff --git a/solanaceae/tox_messages/tox_message_manager.cpp b/solanaceae/tox_messages/tox_message_manager.cpp index 9e8f8d7..fe55423 100644 --- a/solanaceae/tox_messages/tox_message_manager.cpp +++ b/solanaceae/tox_messages/tox_message_manager.cpp @@ -100,7 +100,8 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo ); if (!res.has_value()) { - return true; // not online? TODO: check for other errors + std::cerr << "TMM: failed to send friend message\n"; + //return true; // not online? TODO: check for other errors } } else if ( _cr.any_of(c)