Skip to content
Snippets Groups Projects
Commit ce702f32 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

migration: add daemon's contacts from old conversations

Change-Id: Id3c506c932ae91ec767944fa1dc5d90584ba7157
parent 10c587d6
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "api/interaction.h" #include "api/interaction.h"
// Lrc for migrations // Lrc for migrations
#include "dbus/configurationmanager.h"
#include "person.h" #include "person.h"
#include "account.h" #include "account.h"
#include "accountmodel.h" #include "accountmodel.h"
...@@ -490,7 +491,8 @@ Database::migrateTextHistory() ...@@ -490,7 +491,8 @@ Database::migrateTextHistory()
auto account = AccountModel::instance().getById(peersObject["accountId"].toString().toUtf8()); auto account = AccountModel::instance().getById(peersObject["accountId"].toString().toUtf8());
if (!account) continue; if (!account) continue;
auto accountUri = account->username(); auto accountUri = account->username();
if (accountUri.startsWith("ring:")) { auto isARingContact = accountUri.startsWith("ring:");
if (isARingContact) {
accountUri = accountUri.mid(QString("ring:").length()); accountUri = accountUri.mid(QString("ring:").length());
} }
auto accountIds = select("id", "profiles","uri=:uri", {{":uri", accountUri.toStdString()}}).payloads; auto accountIds = select("id", "profiles","uri=:uri", {{":uri", accountUri.toStdString()}}).payloads;
...@@ -501,9 +503,15 @@ Database::migrateTextHistory() ...@@ -501,9 +503,15 @@ Database::migrateTextHistory()
{":status", "status"}}, {":status", "status"}},
{{":uri", peersObject["uri"].toString().toStdString()}, {":alias", ""}, {{":uri", peersObject["uri"].toString().toStdString()}, {":alias", ""},
{":photo", ""}, {":type", "RING"}, {":photo", ""}, {":type", "RING"},
{":status", "NONTRUSTED"}}); {":status", "TRUSTED"}});
// NOTE: this profile is in a case where it's not a contact for the daemon. So we choose to remove this contact from // NOTE: this profile is in a case where it's not a contact for the daemon but a conversation with an account.
// conversations. // So we choose to add the profile to daemon's contacts
if(isARingContact) {
ConfigurationManager::instance().addContact(
peersObject["accountId"].toString(),
peersObject["uri"].toString()
);
}
contactIds = select("id", "profiles","uri=:uri", {{":uri", peersObject["uri"].toString().toStdString()}}).payloads; contactIds = select("id", "profiles","uri=:uri", {{":uri", peersObject["uri"].toString().toStdString()}}).payloads;
} }
if (accountIds.empty()) { if (accountIds.empty()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment