mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 09:27:09 -05:00
fixed bug causing forum posts to disappear/re-appear and to be set unread again. The bug was due to inconsistency between cleaning old messages and still inserting old messages again. Also augmented the storage period to 4 months (previously 1 month). Challenge: we should keep threads until the newest post in the thread is older than 4 months
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7554 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
9963cca4a6
commit
38c7e50e06
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
#define GXS_MASK "GXS_MASK_HACK"
|
#define GXS_MASK "GXS_MASK_HACK"
|
||||||
|
|
||||||
#define GEN_EXCH_DEBUG 1
|
//#define GEN_EXCH_DEBUG 1
|
||||||
|
|
||||||
#define MSG_CLEANUP_PERIOD 60*5 // 5 minutes
|
#define MSG_CLEANUP_PERIOD 60*5 // 5 minutes
|
||||||
#define INTEGRITY_CHECK_PERIOD 60*30 // 30 minutes
|
#define INTEGRITY_CHECK_PERIOD 60*30 // 30 minutes
|
||||||
@ -87,6 +87,41 @@ RsGenExchange::RsGenExchange(RsGeneralDataService *gds, RsNetworkExchangeService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TO_BE_DELETED_IF_NOT_USEFUL
|
||||||
|
// This class has been tested so as to see where the database gets modified.
|
||||||
|
class RsDataBaseTester
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RsDataBaseTester(RsGeneralDataService *store,const RsGxsGroupId& grpId,const std::string& info)
|
||||||
|
:_grpId(grpId),_store(store),_info(info)
|
||||||
|
{
|
||||||
|
//std::cerr << "RsDataBaseTester: (" << _info << ") retrieving messages for group " << grpId << std::endl;
|
||||||
|
_store->retrieveMsgIds(_grpId, _msgIds1) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
~RsDataBaseTester()
|
||||||
|
{
|
||||||
|
//std::cerr << "RsDataBaseTester: (" << _info << ") testing messages for group " << _grpId << std::endl;
|
||||||
|
_store->retrieveMsgIds(_grpId, _msgIds2) ;
|
||||||
|
|
||||||
|
bool all_idendical = true ;
|
||||||
|
std::cerr << std::dec ;
|
||||||
|
|
||||||
|
if(_msgIds1.size() != _msgIds2.size())
|
||||||
|
std::cerr << " " << _info << " (EE) The two arrays are different (size1=" << _msgIds1.size() << ", size2=" << _msgIds2.size() << ") !!" << std::endl;
|
||||||
|
else
|
||||||
|
for(uint32_t i=0;i<_msgIds1.size();++i)
|
||||||
|
if(_msgIds1[i] != _msgIds2[i])
|
||||||
|
std::cerr << " " << _info << " (EE) The two arrays are different for i=" << i << " !!" << std::endl;
|
||||||
|
}
|
||||||
|
RsGxsGroupId _grpId ;
|
||||||
|
RsGeneralDataService *_store ;
|
||||||
|
std::vector<RsGxsMessageId> _msgIds1 ;
|
||||||
|
std::vector<RsGxsMessageId> _msgIds2 ;
|
||||||
|
std::string _info ;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
RsGenExchange::~RsGenExchange()
|
RsGenExchange::~RsGenExchange()
|
||||||
{
|
{
|
||||||
// need to destruct in a certain order (bad thing, TODO: put down instance ownership rules!)
|
// need to destruct in a certain order (bad thing, TODO: put down instance ownership rules!)
|
||||||
@ -190,6 +225,13 @@ void RsGenExchange::tick()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta)
|
||||||
|
{
|
||||||
|
time_t now = time(NULL) ;
|
||||||
|
|
||||||
|
return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || meta.mPublishTs + MESSAGE_STORE_PERIOD >= now ;
|
||||||
|
}
|
||||||
|
|
||||||
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
|
bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token,
|
||||||
RsGxsGrpMsgIdPair& msgId)
|
RsGxsGrpMsgIdPair& msgId)
|
||||||
{
|
{
|
||||||
@ -1889,7 +1931,6 @@ RsGenExchange::ServiceCreate_Return RsGenExchange::service_CreateGroup(RsGxsGrpI
|
|||||||
|
|
||||||
void RsGenExchange::processGroupUpdatePublish()
|
void RsGenExchange::processGroupUpdatePublish()
|
||||||
{
|
{
|
||||||
|
|
||||||
RsStackMutex stack(mGenMtx);
|
RsStackMutex stack(mGenMtx);
|
||||||
|
|
||||||
// get keys for group update publish
|
// get keys for group update publish
|
||||||
@ -1959,7 +2000,6 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
|
|
||||||
void RsGenExchange::processGroupDelete()
|
void RsGenExchange::processGroupDelete()
|
||||||
{
|
{
|
||||||
|
|
||||||
RsStackMutex stack(mGenMtx);
|
RsStackMutex stack(mGenMtx);
|
||||||
|
|
||||||
// get keys for group delete publish
|
// get keys for group delete publish
|
||||||
@ -2478,7 +2518,7 @@ void RsGenExchange::processRecvdMessages()
|
|||||||
if(!msgIds.empty())
|
if(!msgIds.empty())
|
||||||
{
|
{
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " removing existing messages." << std::endl;
|
std::cerr << " removing existing and old messages from incoming list." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
removeDeleteExistingMessages(msgs, msgIds);
|
removeDeleteExistingMessages(msgs, msgIds);
|
||||||
|
|
||||||
@ -2486,6 +2526,7 @@ void RsGenExchange::processRecvdMessages()
|
|||||||
std::cerr << " storing remaining messages" << std::endl;
|
std::cerr << " storing remaining messages" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
mDataStore->storeMessage(msgs);
|
mDataStore->storeMessage(msgs);
|
||||||
|
|
||||||
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false);
|
RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_RECEIVE, false);
|
||||||
c->msgChangeMap = msgIds;
|
c->msgChangeMap = msgIds;
|
||||||
mNotifications.push_back(c);
|
mNotifications.push_back(c);
|
||||||
@ -2604,7 +2645,6 @@ void RsGenExchange::processRecvdGroups()
|
|||||||
|
|
||||||
void RsGenExchange::performUpdateValidation()
|
void RsGenExchange::performUpdateValidation()
|
||||||
{
|
{
|
||||||
|
|
||||||
RsStackMutex stack(mGenMtx);
|
RsStackMutex stack(mGenMtx);
|
||||||
|
|
||||||
if(mGroupUpdates.empty())
|
if(mGroupUpdates.empty())
|
||||||
@ -2709,9 +2749,8 @@ void RsGenExchange::setGroupReputationCutOff(uint32_t& token, const RsGxsGroupId
|
|||||||
mGrpLocMetaMap.insert(std::make_pair(token, g));
|
mGrpLocMetaMap.insert(std::make_pair(token, g));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RsGenExchange::removeDeleteExistingMessages(
|
void RsGenExchange::removeDeleteExistingMessages( RsGeneralDataService::MsgStoreMap& msgs, GxsMsgReq& msgIdsNotify)
|
||||||
RsGeneralDataService::MsgStoreMap& msgs, GxsMsgReq& msgIdsNotify) {
|
{
|
||||||
|
|
||||||
// first get grp ids of messages to be stored
|
// first get grp ids of messages to be stored
|
||||||
|
|
||||||
RsGxsGroupId::std_set mGrpIdsUnique;
|
RsGxsGroupId::std_set mGrpIdsUnique;
|
||||||
@ -2748,7 +2787,18 @@ void RsGenExchange::removeDeleteExistingMessages(
|
|||||||
|
|
||||||
std::cerr << " grpid=" << cit2->second->mGroupId << ", msgid=" << cit2->second->mMsgId ;
|
std::cerr << " grpid=" << cit2->second->mGroupId << ", msgid=" << cit2->second->mMsgId ;
|
||||||
|
|
||||||
if(std::find(msgIds.begin(), msgIds.end(), cit2->second->mMsgId) != msgIds.end())
|
// Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test)
|
||||||
|
//
|
||||||
|
if(std::find(msgIds.begin(), msgIds.end(), cit2->second->mMsgId) == msgIds.end() && messagePublicationTest(*cit2->second))
|
||||||
|
{
|
||||||
|
// passes tests, so add to filtered list
|
||||||
|
//
|
||||||
|
filtered.insert(*cit2);
|
||||||
|
#ifdef GEN_EXCH_DEBUG
|
||||||
|
std::cerr << " keeping " << cit2->second->mMsgId << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else // remove message from list
|
||||||
{
|
{
|
||||||
// msg exist in retrieved index
|
// msg exist in retrieved index
|
||||||
delete cit2->first;
|
delete cit2->first;
|
||||||
@ -2759,14 +2809,6 @@ void RsGenExchange::removeDeleteExistingMessages(
|
|||||||
notifyIds.erase(it2);
|
notifyIds.erase(it2);
|
||||||
#ifdef GEN_EXCH_DEBUG
|
#ifdef GEN_EXCH_DEBUG
|
||||||
std::cerr << " discarding " << cit2->second->mMsgId << std::endl;
|
std::cerr << " discarding " << cit2->second->mMsgId << std::endl;
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// does not exist so add to filtered list
|
|
||||||
filtered.insert(*cit2);
|
|
||||||
#ifdef GEN_EXCH_DEBUG
|
|
||||||
std::cerr << " keeping " << cit2->second->mMsgId << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include "serialiser/rsnxsitems.h"
|
#include "serialiser/rsnxsitems.h"
|
||||||
#include "rsgxsutil.h"
|
#include "rsgxsutil.h"
|
||||||
|
|
||||||
#define DEFAULT_MSG_STORE_PERIOD 60*60*24*30 // 1 month
|
#define DEFAULT_MSG_STORE_PERIOD 60*60*24*31*4 // 4 months
|
||||||
|
|
||||||
template<class GxsItem, typename Identity = std::string>
|
template<class GxsItem, typename Identity = std::string>
|
||||||
class GxsPendingItem
|
class GxsPendingItem
|
||||||
@ -307,6 +307,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
bool messagePublicationTest(const RsGxsMsgMetaData&) ;
|
||||||
/*!
|
/*!
|
||||||
* retrieves group data associated to a request token
|
* retrieves group data associated to a request token
|
||||||
* @param token token to be redeemed for grpitem retrieval
|
* @param token token to be redeemed for grpitem retrieval
|
||||||
|
@ -1110,7 +1110,7 @@ void MessagesDialog::insertMessages()
|
|||||||
text = "RetroShare";
|
text = "RetroShare";
|
||||||
} else {
|
} else {
|
||||||
text = QString::fromUtf8(rsPeers->getPeerName(it->srcId).c_str());
|
text = QString::fromUtf8(rsPeers->getPeerName(it->srcId).c_str());
|
||||||
std::cerr << "(messages) getting name for id " << it->srcId << " => \"" << text.toStdString() << "\"" << std::endl;
|
//std::cerr << "(messages) getting name for id " << it->srcId << " => \"" << text.toStdString() << "\"" << std::endl;
|
||||||
if(text == "")
|
if(text == "")
|
||||||
{
|
{
|
||||||
RsIdentityDetails details;
|
RsIdentityDetails details;
|
||||||
|
Loading…
Reference in New Issue
Block a user