Skip to content
Snippets Groups Projects
Commit f836d41d authored by Sébastien Blin's avatar Sébastien Blin
Browse files

contact_list: fix isActive() when remove/re-add a contact

Because time_t is in seconds, re-adding a contact just after
removing it can cause isActive() to be false (because
removed == added).

Change-Id: I25a9fa1d6d3cadb152c2d15453179ecf364d0737
GitLab: https://git.jami.net/savoirfairelinux/ring-project/-/issues/1282
parent 1acdde67
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,10 @@ ContactList::addContact(const dht::InfoHash& h, bool confirmed, const std::strin
else if (c->second.isActive() and c->second.confirmed == confirmed)
return false;
c->second.added = std::time(nullptr);
// NOTE: because we can re-add a contact after removing it
// we should reset removed (as not removed anymore). This fix isActive()
// if addContact is called just after removeContact during the same second
c->second.removed = 0;
c->second.conversationId = conversationId;
c->second.confirmed |= confirmed;
auto hStr = h.toString();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment