From d74cc97395bc00e688c365ed83d4d9dd0aa851a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= Date: Tue, 26 Jul 2022 14:44:09 -0400 Subject: [PATCH] swarm: compress avatar to send in conversation's request As it's sent over the DHT, the max value is 64k, also, even if sent as a SIP message (if member was already connected and we add a new non 1:1 swarm with this contact), the sendSIPMessage will fail due to a too large message (PJSIP_EMSGTOOLONG). Change-Id: I7908809fe2c3f6e08f9a4b9c6f8aac654ab86c42 --- src/libclient/authority/storagehelper.cpp | 2 -- src/libclient/authority/storagehelper.h | 2 ++ src/libclient/conversationmodel.cpp | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libclient/authority/storagehelper.cpp b/src/libclient/authority/storagehelper.cpp index 395dc77c..758e630f 100644 --- a/src/libclient/authority/storagehelper.cpp +++ b/src/libclient/authority/storagehelper.cpp @@ -206,8 +206,6 @@ getContactInteractionString(const QString& authorUri, const api::interaction::St } namespace vcard { -QString compressedAvatar(const QString& image); - QString compressedAvatar(const QString& image) { diff --git a/src/libclient/authority/storagehelper.h b/src/libclient/authority/storagehelper.h index a5060fd5..2dc68a31 100644 --- a/src/libclient/authority/storagehelper.h +++ b/src/libclient/authority/storagehelper.h @@ -73,6 +73,8 @@ QString getContactInteractionString(const QString& authorUri, namespace vcard { +QString compressedAvatar(const QString& image); + /** * Build the vCard for a profile * @param profileInfo diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index d3a79dda..1cacfaf7 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -986,7 +986,11 @@ ConversationModel::createConversation(const VectorString& participants, const Ma void ConversationModel::updateConversationInfos(const QString& conversationId, const MapStringString info) { - ConfigurationManager::instance().updateConversationInfos(owner.id, conversationId, info); + MapStringString newInfos = info; + // Compress avatar as it will be sent in the conversation's request over the DHT + if (info.contains("avatar")) + newInfos["avatar"] = storage::vcard::compressedAvatar(info["avatar"]); + ConfigurationManager::instance().updateConversationInfos(owner.id, conversationId, newInfos); } bool