mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
conversation: avoid to get lastCommitId while merging
Change-Id: I2a7b7cc13268be127a6afe3d689d005b6596a3cd
This commit is contained in:
@ -1596,10 +1596,10 @@ Conversation::lastCommitId() const
|
||||
options.nbOfCommits = 1;
|
||||
options.skipMerge = true;
|
||||
History optHistory;
|
||||
std::lock_guard wlk(pimpl_->writeMtx_); // Avoid any write during a loading operation
|
||||
std::lock_guard lk(pimpl_->historyMtx_);
|
||||
if (!pimpl_->loadedHistory_.messageList.empty()) {
|
||||
if (!pimpl_->loadedHistory_.messageList.empty())
|
||||
return (*pimpl_->loadedHistory_.messageList.begin())->id;
|
||||
}
|
||||
auto res = pimpl_->loadMessages2(options, &optHistory);
|
||||
if (res.empty())
|
||||
return {};
|
||||
|
@ -872,9 +872,9 @@ ConversationModule::Impl::removeRepositoryImpl(SyncedConversation& conv, bool sy
|
||||
JAMI_LOG("Remove conversation: {}", conv.info.id);
|
||||
try {
|
||||
if (conv.conversation->mode() == ConversationMode::ONE_TO_ONE) {
|
||||
auto account = account_.lock();
|
||||
for (const auto& member : conv.conversation->getInitialMembers()) {
|
||||
if (member != account->getUsername()) {
|
||||
auto account = account_.lock();
|
||||
if (member != account->getUsername()) {
|
||||
// Note: this can happen while re-adding a contact.
|
||||
// In this case, check that we are removing the linked conversation.
|
||||
if (conv.info.id == getOneToOneConversation(member)) {
|
||||
@ -2254,7 +2254,7 @@ ConversationModule::onSyncData(const SyncMsg& msg,
|
||||
// If multi devices, it can detect a conversation that was already
|
||||
// removed, so just check if the convinfo contains a removed conv
|
||||
if (conv->info.removed) {
|
||||
if (conv->info.removed > convInfo.created) {
|
||||
if (conv->info.removed >= convInfo.created) {
|
||||
// Only reclone if re-added, else the peer is not synced yet (could be
|
||||
// offline before)
|
||||
continue;
|
||||
|
@ -576,6 +576,8 @@ ConversationMembersEventTest::testAddOfflineMemberThenConnects()
|
||||
auto aliceMsgSize = aliceData.messages.size();
|
||||
libjami::addConversationMember(aliceId, convId, carlaUri);
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceMsgSize + 1 == aliceData.messages.size(); }));
|
||||
CPPUNIT_ASSERT(!cv.wait_for(lk, 30s, [&] { return carlaData.requestReceived; }));
|
||||
|
||||
Manager::instance().sendRegister(carlaId, true);
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 60s, [&] { return carlaData.requestReceived; }));
|
||||
|
||||
@ -929,7 +931,8 @@ ConversationMembersEventTest::testMemberCannotBanOther()
|
||||
// remove from member & add into banned without voting for the ban
|
||||
simulateRemoval(carlaAccount, convId, bobUri);
|
||||
// Note: it may be possible that alice doesn't get the error if they got messages from bob (and bob rejects due to an error)
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return aliceData.errorDetected || bobData.errorDetected; }));
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() {
|
||||
return aliceData.errorDetected || bobData.errorDetected; }));
|
||||
|
||||
auto bobMsgSize = bobData.messages.size();
|
||||
libjami::sendMessage(aliceId, convId, "hi"s, "");
|
||||
@ -966,7 +969,7 @@ ConversationMembersEventTest::testMemberCannotUnBanOther()
|
||||
cv.wait_for(lk, 30s, [&]() { return !carlaData.conversationId.empty()
|
||||
&& aliceData.members[carlaUri] == 1
|
||||
&& bobData.members[carlaUri] == 1; }));
|
||||
|
||||
std::this_thread::sleep_for(3s); // Wait that carla finish the clone
|
||||
// Now check that alice, has the only admin, can remove bob
|
||||
libjami::removeConversationMember(aliceId, convId, bobUri);
|
||||
CPPUNIT_ASSERT(
|
||||
@ -1443,7 +1446,8 @@ ConversationMembersEventTest::testAvoidTwoOneToOneMultiDevices()
|
||||
bobAccount->addContact(aliceUri);
|
||||
bobAccount->sendTrustRequest(aliceUri, {});
|
||||
CPPUNIT_ASSERT(
|
||||
cv.wait_for(lk, 30s, [&]() { return bobData.conversationId == aliceData.conversationId && bob2Data.conversationId == aliceData.conversationId; }));
|
||||
cv.wait_for(lk, 30s, [&]() {
|
||||
return bobData.conversationId == aliceData.conversationId && bob2Data.conversationId == aliceData.conversationId; }));
|
||||
}
|
||||
|
||||
void
|
||||
@ -1696,7 +1700,6 @@ ConversationMembersEventTest::testBanFromNewDevice()
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return bob2Data.deviceAnnounced; }));
|
||||
CPPUNIT_ASSERT(cv.wait_for(lk, 30s, [&]() { return !bob2Data.conversationId.empty(); }));
|
||||
|
||||
|
||||
auto bobMsgSize = bobData.messages.size();
|
||||
libjami::removeConversationMember(bob2Id, convId, aliceUri);
|
||||
CPPUNIT_ASSERT(
|
||||
|
Reference in New Issue
Block a user