fixed load/save of chat history for distant chat

This commit is contained in:
csoler 2019-10-14 00:07:11 +02:00
parent 09343e9179
commit b3156223af
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 18 additions and 8 deletions

View File

@ -417,10 +417,10 @@ bool p3ChatService::sendChat(ChatId destination, std::string msg)
RsServer::notify()->notifyChatMessage(message);
// cyril: history is temporarily diabled for distant chat, since we need to store the full tunnel ID, but then
// cyril: history is temporarily disabled for distant chat, since we need to store the full tunnel ID, but then
// at loading time, the ID is not known so that chat window shows 00000000 as a peer.
if(!message.chat_id.isDistantChatId())
//if(!message.chat_id.isDistantChatId())
mHistoryMgr->addMessage(message);
checkSizeAndSendMessage(ci);
@ -876,10 +876,6 @@ bool p3ChatService::handleRecvChatMsgItem(RsChatMsgItem *& ci)
cm.online = true;
RsServer::notify()->notifyChatMessage(cm);
// cyril: history is temporarily diabled for distant chat, since we need to store the full tunnel ID, but then
// at loading time, the ID is not known so that chat window shows 00000000 as a peer.
if(!cm.chat_id.isDistantChatId())
mHistoryMgr->addMessage(cm);
return true ;

View File

@ -113,7 +113,7 @@ int p3GxsTunnelService::tick()
flush() ;
rstime::rs_usleep(1000*200);
rstime::rs_usleep(1000*500);
return 0 ;
}

View File

@ -103,7 +103,21 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
{
DistantChatPeerInfo dcpinfo;
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
peerName = cm.chat_id.toPeerId().toStdString();
{
RsIdentityDetails det;
RsGxsId writer_id = cm.incoming?(dcpinfo.to_id):(dcpinfo.own_id);
if(rsIdentity->getIdDetails(writer_id,det))
peerName = det.mNickname;
else
peerName = writer_id.toStdString();
}
else
{
RsErr() << "Cannot retrieve friend name for distant chat " << cm.chat_id.toDistantChatId() << std::endl;
peerName = "";
}
enabled = true;
}