Fix NickName in Chat Lobby when starting

This commit is contained in:
Phenom 2021-01-22 15:55:41 +01:00
parent 4fa5aa6c2c
commit b2baf89758

View File

@ -41,23 +41,14 @@
RsHistory *rsHistory = NULL;
p3HistoryMgr::p3HistoryMgr()
: p3Config(), mHistoryMtx("p3HistoryMgr")
: p3Config()
, nextMsgId(1)
, mPublicEnable(false), mLobbyEnable(true), mPrivateEnable(true), mDistantEnable(true)
, mPublicSaveCount(0), mLobbySaveCount(0), mPrivateSaveCount(0), mDistantSaveCount(0)
, mMaxStorageDurationSeconds(10*86400) // store for 10 days at most.
, mLastCleanTime(0)
, mHistoryMtx("p3HistoryMgr")
{
nextMsgId = 1;
mPublicEnable = false;
mPrivateEnable = true;
mLobbyEnable = true;
mDistantEnable = true;
mPublicSaveCount = 0;
mLobbySaveCount = 0;
mPrivateSaveCount = 0;
mDistantSaveCount = 0;
mLastCleanTime = 0 ;
mMaxStorageDurationSeconds = 10*86400 ; // store for 10 days at most.
}
p3HistoryMgr::~p3HistoryMgr()
@ -81,28 +72,26 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
{
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
RsPeerId msgPeerId; // id of sending peer
RsPeerId chatPeerId; // id of chat endpoint
std::string peerName; //name of sending peer
bool enabled = false;
if (cm.chat_id.isBroadcast() && mPublicEnable == true) {
peerName = rsPeers->getPeerName(cm.broadcast_peer_id);
enabled = true;
}
if (cm.chat_id.isPeerId() && mPrivateEnable == true) {
else if (cm.chat_id.isPeerId() && mPrivateEnable == true) {
msgPeerId = cm.incoming ? cm.chat_id.toPeerId() : rsPeers->getOwnId();
peerName = rsPeers->getPeerName(msgPeerId);
enabled = true;
}
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
peerName = cm.lobby_peer_gxs_id.toStdString();
else if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
enabled = true;
RsIdentityDetails details;
if (rsIdentity->getIdDetails(cm.lobby_peer_gxs_id, details))
peerName = details.mNickname;
else
peerName = cm.lobby_peer_gxs_id.toStdString();
}
if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
else if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
{
DistantChatPeerInfo dcpinfo;
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
@ -119,14 +108,12 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
}
else
{
RsErr() << "Cannot retrieve friend name for distant chat " << cm.chat_id.toDistantChatId() << std::endl;
RS_ERR( "Cannot retrieve friend name for distant chat ", cm.chat_id.toDistantChatId() );
peerName = "";
}
enabled = true;
}
if(enabled == false)
else
return;
if(!chatIdToVirtualPeerId(cm.chat_id, chatPeerId))