Fixed fileTransferContent values not being set from content's body when fetched from db

This commit is contained in:
Sylvain Berfini 2017-12-05 15:37:05 +01:00
parent 8f1ee5a06d
commit c48f0f70b5
3 changed files with 17 additions and 1 deletions

View file

@ -86,6 +86,8 @@ public:
void removeSalCustomHeader(const std::string& name);
std::string getSalCustomHeaderValue(const std::string& name);
void loadFileTransferUrlFromBodyToContent();
// -----------------------------------------------------------------------------
// Deprecated methods only used for C wrapper, to be removed some day...
// -----------------------------------------------------------------------------

View file

@ -305,6 +305,12 @@ bool ChatMessagePrivate::downloadFile () {
return false;
}
void ChatMessagePrivate::loadFileTransferUrlFromBodyToContent() {
L_Q();
int errorCode = 0;
fileTransferChatMessageModifier.decode(q->getSharedFromThis(), errorCode);
}
// -----------------------------------------------------------------------------
void ChatMessagePrivate::sendImdn (Imdn::Type imdnType, LinphoneReason reason) {
@ -375,7 +381,7 @@ LinphoneReason ChatMessagePrivate::receive () {
lInfo() << "File download step already done, skipping";
} else {
// This will check if internal content is FileTransfer and make the appropriate changes
fileTransferChatMessageModifier.decode(q->getSharedFromThis(), errorCode);
loadFileTransferUrlFromBodyToContent();
currentRecvStep |= ChatMessagePrivate::Step::FileUpload;
}

View file

@ -440,6 +440,8 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
if (!chatRoom)
return nullptr;
bool hasFileTransferContent = false;
// 1 - Fetch chat message.
shared_ptr<ChatMessage> chatMessage = getChatMessageFromCache(eventId);
if (chatMessage)
@ -528,6 +530,12 @@ MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate),
}
}
// 3 - Load external body url from body into FileTransferContent if needed
if (hasFileTransferContent) {
ChatMessagePrivate *dChatMessage = chatMessage->getPrivate();
dChatMessage->loadFileTransferUrlFromBodyToContent();
}
cache(chatMessage, eventId);
end: