Skip to content
Snippets Groups Projects
Commit da949e2b authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

swarm: remove memberless conversations from the to-sync list

If somehow we have obtained a convInfo file with invalid conversations
(reproducible during a post link account sync), remove them when
loading the conversations.

Gitlab: #528
Change-Id: I45f759f470e58f567e70abafaca21dcce728183f
parent c2b167da
No related branches found
No related tags found
No related merge requests found
...@@ -600,12 +600,21 @@ ConversationModule::loadConversations() ...@@ -600,12 +600,21 @@ ConversationModule::loadConversations()
} }
pimpl_->convInfos_ = convInfos(pimpl_->accountId_); pimpl_->convInfos_ = convInfos(pimpl_->accountId_);
// Set removed flag // Prune any invalid conversations without members and
// set the removed flag if needed
size_t oldConvInfosSize = pimpl_->convInfos_.size();
for (auto& [key, info] : pimpl_->convInfos_) { for (auto& [key, info] : pimpl_->convInfos_) {
if (info.members.empty()) {
pimpl_->convInfos_.erase(key);
continue;
}
auto itConv = pimpl_->conversations_.find(info.id); auto itConv = pimpl_->conversations_.find(info.id);
if (itConv != pimpl_->conversations_.end() && info.removed) if (itConv != pimpl_->conversations_.end() && info.removed)
itConv->second->setRemovingFlag(); itConv->second->setRemovingFlag();
} }
// Save iff we've removed some invalid entries
if (oldConvInfosSize != pimpl_->convInfos_.size())
pimpl_->saveConvInfos();
JAMI_INFO("[Account %s] Conversations loaded!", pimpl_->accountId_.c_str()); JAMI_INFO("[Account %s] Conversations loaded!", pimpl_->accountId_.c_str());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment