conversation_module: try to clone requests on bootstrap

Since the DRT, we're not using trackPresence to start syncing
with other members of the conversation but "bootstrap".
For bootstraping conversation's requests we should try to clone
it with the members marked in the convInfo.

Change-Id: I4095ee59d56a28c4a24f8f4ddd9116109e6d0b7c
This commit is contained in:
Sébastien Blin
2023-06-07 10:15:32 -04:00
parent 2a4149eb68
commit 65c8631975
2 changed files with 22 additions and 5 deletions

View File

@ -1262,15 +1262,33 @@ ConversationModule::bootstrap(const std::string& convId)
std::bind(&ConversationModule::Impl::bootstrapCb, pimpl_.get(), conv->id()), kd);
}
};
std::vector<std::string> toClone;
std::unique_lock<std::mutex> lk(pimpl_->conversationsMtx_);
std::unique_lock<std::mutex> lkCi(pimpl_->convInfosMtx_);
if (convId.empty()) {
for (auto& [_, conv] : pimpl_->conversations_) {
bootstrap(conv);
for (const auto& [key, ci] : pimpl_->convInfos_) {
auto it = pimpl_->conversations_.find(key);
if (it != pimpl_->conversations_.end() && it->second) {
bootstrap(it->second);
} else {
// Because we're not tracking contact presence in order to sync now,
// we need to ask to clone requests when bootstraping all conversations
// else it can stay syncing
toClone.emplace_back(key);
}
}
} else {
auto it = pimpl_->conversations_.find(convId);
if (it != pimpl_->conversations_.end()) {
if (it != pimpl_->conversations_.end())
bootstrap(it->second);
}
lkCi.unlock();
lk.unlock();
for (const auto& cid: toClone) {
auto members = getConversationMembers(cid);
for (const auto& member : members) {
if (member.at("uri") != pimpl_->username_)
cloneConversationFrom(cid, member.at("uri"));
}
}
}

View File

@ -689,8 +689,7 @@ SyncHistoryTest::testSyncCreateAccountExportDeleteReimportWithConvId()
conversationReady = false;
alice2Id = Manager::instance().addAccount(details);
// Should retrieve conversation, no need for action as the convInfos is in the archive
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return alice2Ready; }));
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return conversationReady; }));
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&] { return alice2Ready && conversationReady; }));
messageBobReceived = 0;
libjami::sendMessage(alice2Id, convId, std::string("hi"), "");