fix tox clients reconnecting

This commit is contained in:
Green Sky 2023-08-02 20:18:20 +02:00
parent a262ab9d3a
commit 3c25162ba1
No known key found for this signature in database
2 changed files with 11 additions and 3 deletions

View File

@ -118,6 +118,9 @@ Contact3Handle ToxContactModel2::getContactFriend(uint32_t friend_number) {
} }
if (_cr.valid(c)) { if (_cr.valid(c)) {
// param friend number matches pubkey in db, add
_cr.emplace_or_replace<Contact::Components::ToxFriendEphemeral>(c, friend_number);
return {_cr, c}; return {_cr, c};
} }
@ -167,6 +170,9 @@ Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) {
} }
if (_cr.valid(c)) { if (_cr.valid(c)) {
// param group number matches pubkey in db, add
_cr.emplace_or_replace<Contact::Components::ToxGroupEphemeral>(c, group_number);
return {_cr, c}; return {_cr, c};
} }
@ -224,8 +230,6 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint
// else check by key // else check by key
auto [g_p_key_opt, _] = _t.toxGroupPeerGetPublicKey(group_number, peer_number); 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? //assert(g_p_key_opt.has_value()); // TODO: handle gracefully?
if (!g_p_key_opt.has_value()) { 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) // 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)) { if (_cr.valid(c)) {
// param numbers matches pubkey in db, add
_cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
return {_cr, c}; return {_cr, c};
} }

View File

@ -100,7 +100,8 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
); );
if (!res.has_value()) { 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 ( } else if (
_cr.any_of<Contact::Components::ToxGroupEphemeral>(c) _cr.any_of<Contact::Components::ToxGroupEphemeral>(c)