From f1ae077f75a603dd7b8b69655baeefc1000d5e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 6 Jul 2021 16:32:09 -0400 Subject: [PATCH] contactmodel: slotProfileReceived can return profile for account Replace profile when account has no avatar and another device announce an avatar for this account Change-Id: Iec473380e5e249ab7b069a811eb82468d168e3bb --- src/contactmodel.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index dd2b33d1..b73de18f 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -1171,7 +1171,6 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, in.setCodec("UTF-8"); auto vCard = in.readAll(); - vCardFile.remove(); profile::Info profileInfo; profileInfo.uri = peer; @@ -1183,6 +1182,21 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, else if (e.contains("FN")) profileInfo.alias = e.split(":")[1]; + if (peer == linked.owner.profileInfo.uri) { + if (linked.owner.profileInfo.avatar.isEmpty() && !profileInfo.avatar.isEmpty()) { + auto dest = storage::getPath() + accountId + "/profile.vcf"; + QFile oldvCard(dest); + if (oldvCard.exists()) + oldvCard.remove(); + vCardFile.rename(dest); + linked.owner.accountModel->setAlias(linked.owner.id, profileInfo.alias); + linked.owner.accountModel->setAvatar(linked.owner.id, profileInfo.avatar); + emit linked.profileUpdated(peer); + } + return; + } + vCardFile.remove(); + contact::Info contactInfo; contactInfo.profileInfo = profileInfo; -- GitLab