Merge pull request #2241 from PhenomRetroShare/Fix_NickNameChatLobbyHistory

Fix NickName in Chat Lobby when starting
This commit is contained in:
csoler 2021-01-23 13:26:05 +01:00 committed by GitHub
commit 3d83431f41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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,52 +72,48 @@ 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();
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
enabled = true;
else if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
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))
{
RsIdentityDetails det;
RsGxsId writer_id = cm.incoming?(dcpinfo.to_id):(dcpinfo.own_id);
{
RsIdentityDetails det;
RsGxsId writer_id = cm.incoming?(dcpinfo.to_id):(dcpinfo.own_id);
if(rsIdentity->getIdDetails(writer_id,det))
if(rsIdentity->getIdDetails(writer_id,det))
peerName = det.mNickname;
else
else
peerName = writer_id.toStdString();
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
}
else
{
RsErr() << "Cannot retrieve friend name for distant chat " << cm.chat_id.toDistantChatId() << std::endl;
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
}
else
{
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))