mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
Fix NickName in Chat Lobby when starting
This commit is contained in:
parent
4fa5aa6c2c
commit
b2baf89758
@ -41,23 +41,14 @@
|
|||||||
RsHistory *rsHistory = NULL;
|
RsHistory *rsHistory = NULL;
|
||||||
|
|
||||||
p3HistoryMgr::p3HistoryMgr()
|
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()
|
p3HistoryMgr::~p3HistoryMgr()
|
||||||
@ -81,52 +72,48 @@ void p3HistoryMgr::addMessage(const ChatMessage& cm)
|
|||||||
{
|
{
|
||||||
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
|
||||||
RsPeerId msgPeerId; // id of sending peer
|
RsPeerId msgPeerId; // id of sending peer
|
||||||
RsPeerId chatPeerId; // id of chat endpoint
|
RsPeerId chatPeerId; // id of chat endpoint
|
||||||
std::string peerName; //name of sending peer
|
std::string peerName; //name of sending peer
|
||||||
|
|
||||||
bool enabled = false;
|
|
||||||
if (cm.chat_id.isBroadcast() && mPublicEnable == true) {
|
if (cm.chat_id.isBroadcast() && mPublicEnable == true) {
|
||||||
peerName = rsPeers->getPeerName(cm.broadcast_peer_id);
|
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();
|
msgPeerId = cm.incoming ? cm.chat_id.toPeerId() : rsPeers->getOwnId();
|
||||||
peerName = rsPeers->getPeerName(msgPeerId);
|
peerName = rsPeers->getPeerName(msgPeerId);
|
||||||
enabled = true;
|
|
||||||
}
|
}
|
||||||
if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
|
else if (cm.chat_id.isLobbyId() && mLobbyEnable == true) {
|
||||||
peerName = cm.lobby_peer_gxs_id.toStdString();
|
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
|
||||||
msgPeerId = RsPeerId(cm.lobby_peer_gxs_id);
|
RsIdentityDetails details;
|
||||||
enabled = true;
|
if (rsIdentity->getIdDetails(cm.lobby_peer_gxs_id, details))
|
||||||
|
peerName = details.mNickname;
|
||||||
|
else
|
||||||
|
peerName = cm.lobby_peer_gxs_id.toStdString();
|
||||||
}
|
}
|
||||||
|
else if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
|
||||||
if(cm.chat_id.isDistantChatId()&& mDistantEnable == true)
|
|
||||||
{
|
{
|
||||||
DistantChatPeerInfo dcpinfo;
|
DistantChatPeerInfo dcpinfo;
|
||||||
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
|
if (rsMsgs->getDistantChatStatus(cm.chat_id.toDistantChatId(), dcpinfo))
|
||||||
{
|
{
|
||||||
RsIdentityDetails det;
|
RsIdentityDetails det;
|
||||||
RsGxsId writer_id = cm.incoming?(dcpinfo.to_id):(dcpinfo.own_id);
|
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;
|
peerName = det.mNickname;
|
||||||
else
|
else
|
||||||
peerName = writer_id.toStdString();
|
peerName = writer_id.toStdString();
|
||||||
|
|
||||||
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
|
msgPeerId = cm.incoming?RsPeerId(dcpinfo.own_id):RsPeerId(dcpinfo.to_id);
|
||||||
}
|
}
|
||||||
else
|
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 = "";
|
peerName = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled = true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if(enabled == false)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!chatIdToVirtualPeerId(cm.chat_id, chatPeerId))
|
if(!chatIdToVirtualPeerId(cm.chat_id, chatPeerId))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user