added missing time stamp of msgServerUpdateMap when posting a new message

This commit is contained in:
csoler 2016-08-01 14:43:17 +02:00
parent 5fac5a8d76
commit b1288bcb7e
5 changed files with 53 additions and 10 deletions

View File

@ -2019,6 +2019,9 @@ void RsGenExchange::publishMsgs()
delete[] metaDataBuff;
if(mNetService != NULL)
mNetService->stampMsgServerUpdateTS(grpId) ;
// add to published to allow acknowledgement
mMsgNotify.insert(std::make_pair(mit->first, std::make_pair(grpId, msgId)));
mDataAccess->updatePublicRequestStatus(mit->first, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE);

View File

@ -595,6 +595,14 @@ public:
*/
void setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId& grpId, int CutOff);
/*!
*
* @param token value set to be redeemed with acknowledgement
* @param grpId group id of the group to update
* @param CutOff The cut off value to set
*/
void updateGroupLastMsgTimeStamp(uint32_t& token, const RsGxsGroupId& grpId);
/*!
* @return storage time of messages in months
*/

View File

@ -761,11 +761,11 @@ void RsGxsNetService::syncWithPeers()
msg->updateTS = updateTS;
if(encrypt_to_this_circle_id.isNull())
msg->grpId = grpId;
msg->grpId = grpId;
else
{
msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ;
msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ;
msg->grpId = hashGrpId(grpId,mNetMgr->getOwnId()) ;
msg->flag |= RsNxsSyncMsgReqItem::FLAG_USE_HASHED_GROUP_ID ;
}
#ifdef NXS_NET_DEBUG_7
@ -2096,14 +2096,16 @@ void RsGxsNetService::updateServerSyncTS()
else
msui = mapIT->second;
if(grpMeta->mLastPost > msui->msgUpdateTS )
{
change = true;
msui->msgUpdateTS = grpMeta->mLastPost;
// (cyril) I'm removing this, becuse mLastPost is *never* updated. So this code it not useful at all.
//
// if(grpMeta->mLastPost > msui->msgUpdateTS )
// {
// change = true;
// msui->msgUpdateTS = grpMeta->mLastPost;
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl;
// GXSNETDEBUG__G(grpId) << " updated msgUpdateTS to last post = " << time(NULL) - grpMeta->mLastPost << " secs ago for group "<< grpId << std::endl;
#endif
}
// }
// This is needed for group metadata updates to actually propagate: only a new grpUpdateTS will trigger the exchange of groups mPublishTs which
// will then be compared and pssibly trigger a MetaData transmission. mRecvTS is upated when creating, receiving for the first time, or receiving
@ -2123,6 +2125,7 @@ void RsGxsNetService::updateServerSyncTS()
if(change)
IndicateConfigChanged();
}
bool RsGxsNetService::locked_checkTransacTimedOut(NxsTransaction* tr)
{
return tr->mTimeOut < ((uint32_t) time(NULL));
@ -4891,3 +4894,22 @@ bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& gro
return true ;
}
bool RsGxsNetService::stampMsgServerUpdateTS(const RsGxsGroupId& gid)
{
RS_STACK_MUTEX(mNxsMutex) ;
std::map<RsGxsGroupId,RsGxsServerMsgUpdateItem*>::iterator it = mServerMsgUpdateMap.find(gid) ;
if(mServerMsgUpdateMap.end() == it)
{
RsGxsServerMsgUpdateItem *item = new RsGxsServerMsgUpdateItem(mServType);
item->grpId = gid ;
item->msgUpdateTS = time(NULL) ;
}
else
it->second->msgUpdateTS = time(NULL) ;
return true;
}

View File

@ -155,7 +155,8 @@ public:
virtual void rejectMessage(const RsGxsMessageId& msg_id) ;
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) ;
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) ;
/* p3Config methods */
public:

View File

@ -144,6 +144,15 @@ public:
* \return false if the group is not found, true otherwise
*/
virtual bool getGroupServerUpdateTS(const RsGxsGroupId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) =0;
/*!
* \brief stampMsgServerUpdateTS
* Updates the msgServerUpdateMap structure to time(NULL), so as to trigger sending msg lists to friends.
* This is needed when e.g. posting a new message to a group.
* \param gid the group to stamp in msgServerUpdateMap
* \return
*/
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) =0;
};
#endif // RSGNP_H