mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
conversation_module: retry to sync if first connection fails
If first connection fails and presence is not tracked, the conversation will not sync until the receiver restarts its jami, causing the conversation to be stuck a very long time even if peer is online and can sync. In this patch, if we receives a trust request, we retry to sync (this will be the case because the sender will re-send a trust request to the contact who is still detected as an invited member) GitLab: #922 Change-Id: I8866ceda98d50b0ddd2ea5402ef34f067f560e97
This commit is contained in:
@ -60,6 +60,7 @@ public:
|
||||
void testAddMember();
|
||||
void testMemberAddedNoBadFile();
|
||||
void testAddOfflineMemberThenConnects();
|
||||
void testAddAcceptOfflineThenConnects();
|
||||
void testGetMembers();
|
||||
void testRemoveMember();
|
||||
void testRemovedMemberDoesNotReceiveMessage();
|
||||
@ -105,6 +106,7 @@ private:
|
||||
CPPUNIT_TEST(testAddMember);
|
||||
CPPUNIT_TEST(testMemberAddedNoBadFile);
|
||||
CPPUNIT_TEST(testAddOfflineMemberThenConnects);
|
||||
CPPUNIT_TEST(testAddAcceptOfflineThenConnects);
|
||||
CPPUNIT_TEST(testGetMembers);
|
||||
CPPUNIT_TEST(testRemoveMember);
|
||||
CPPUNIT_TEST(testRemovedMemberDoesNotReceiveMessage);
|
||||
@ -468,13 +470,54 @@ ConversationMembersEventTest::testAddOfflineMemberThenConnects()
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return requestReceived; }));
|
||||
|
||||
libjami::acceptConversationRequest(carlaId, convId);
|
||||
cv.wait_for(lk, 30s, [&]() { return conversationReady; });
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return conversationReady; }));
|
||||
auto clonedPath = fileutils::get_data_dir() / carlaAccount->getAccountID()
|
||||
/ "conversations" / convId;
|
||||
CPPUNIT_ASSERT(std::filesystem::is_directory(clonedPath));
|
||||
libjami::unregisterSignalHandlers();
|
||||
}
|
||||
|
||||
void
|
||||
ConversationMembersEventTest::testAddAcceptOfflineThenConnects()
|
||||
{
|
||||
auto aliceAccount = Manager::instance().getAccount<JamiAccount>(aliceId);
|
||||
auto bobAccount = Manager::instance().getAccount<JamiAccount>(bobId);
|
||||
auto bobUri = bobAccount->getUsername();
|
||||
|
||||
auto convId = libjami::startConversation(aliceId);
|
||||
|
||||
std::map<std::string, std::shared_ptr<libjami::CallbackWrapperBase>> confHandlers;
|
||||
bool conversationReady = false, requestReceived = false;
|
||||
confHandlers.insert(libjami::exportable_callback<libjami::ConversationSignal::ConversationReady>(
|
||||
[&](const std::string& accountId, const std::string& /* conversationId */) {
|
||||
if (accountId == bobId) {
|
||||
conversationReady = true;
|
||||
cv.notify_one();
|
||||
}
|
||||
}));
|
||||
confHandlers.insert(
|
||||
libjami::exportable_callback<libjami::ConversationSignal::ConversationRequestReceived>(
|
||||
[&](const std::string& /*accountId*/,
|
||||
const std::string& /* conversationId */,
|
||||
std::map<std::string, std::string> /*metadatas*/) {
|
||||
requestReceived = true;
|
||||
cv.notify_one();
|
||||
}));
|
||||
libjami::registerSignalHandlers(confHandlers);
|
||||
|
||||
libjami::addConversationMember(aliceId, convId, bobUri);
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return requestReceived; }));
|
||||
|
||||
Manager::instance().sendRegister(aliceId, false); // This avoid to sync immediately
|
||||
libjami::acceptConversationRequest(bobId, convId);
|
||||
|
||||
std::this_thread::sleep_for(40s); // Wait for negotiation to timeout
|
||||
|
||||
Manager::instance().sendRegister(aliceId, true); // This avoid to sync immediately
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return conversationReady; }));
|
||||
libjami::unregisterSignalHandlers();
|
||||
}
|
||||
|
||||
void
|
||||
ConversationMembersEventTest::testGetMembers()
|
||||
{
|
||||
|
Reference in New Issue
Block a user