mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
* Added extra forum sorting method: Last Post.
This will hopefully be more useful than the existing ones. Extra childTS field was added & populated. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1628 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a436af418a
commit
821855d16e
@ -69,6 +69,7 @@ class ForumMsgInfo
|
||||
std::wstring title;
|
||||
std::wstring msg;
|
||||
time_t ts;
|
||||
time_t childTS;
|
||||
};
|
||||
|
||||
|
||||
@ -87,7 +88,7 @@ class ThreadInfoSummary
|
||||
std::wstring msg;
|
||||
int count; /* file count */
|
||||
time_t ts;
|
||||
|
||||
time_t childTS;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const ForumInfo &info);
|
||||
|
@ -59,7 +59,8 @@ virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/* Not Serialised */
|
||||
|
||||
std::string msgId; /* Msg Id */
|
||||
std::string msgId; /* Msg Id */
|
||||
uint32_t childTS; /* timestamp of most recent child */
|
||||
RsTlvKeySignature publishSignature;
|
||||
RsTlvKeySignature personalSignature;
|
||||
};
|
||||
|
@ -624,6 +624,9 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
|
||||
/* accept message */
|
||||
(git->second).msgs[msg->msgId] = msg;
|
||||
|
||||
/* now update parents TS */
|
||||
locked_updateChildTS(git->second, msg);
|
||||
|
||||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::loadMsg() Msg Loaded Successfully" << std::endl;
|
||||
std::cerr << std::endl;
|
||||
@ -2567,6 +2570,42 @@ bool p3GroupDistrib::locked_checkDistribMsg(
|
||||
}
|
||||
|
||||
|
||||
/* now update parents TS */
|
||||
bool p3GroupDistrib::locked_updateChildTS(GroupInfo &gi, RsDistribMsg *msg)
|
||||
{
|
||||
/* find all parents - update timestamp */
|
||||
time_t updateTS = msg->timestamp;
|
||||
msg->childTS = updateTS;
|
||||
|
||||
while("" != msg->parentId)
|
||||
{
|
||||
std::string parentId = msg->parentId;
|
||||
|
||||
std::map<std::string, RsDistribMsg *>::iterator mit;
|
||||
if (gi.msgs.end() == (mit = gi.msgs.find(parentId)))
|
||||
{
|
||||
/* not found - abandon */
|
||||
return true;
|
||||
}
|
||||
RsDistribMsg *parent = mit->second;
|
||||
if ((!parent) || (parent->childTS > updateTS))
|
||||
{
|
||||
/* we're too old - give up! */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* update timestamp */
|
||||
parent->childTS = updateTS;
|
||||
msg = parent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***** DEBUG *****/
|
||||
|
||||
void p3GroupDistrib::printGroups(std::ostream &out)
|
||||
|
@ -329,6 +329,7 @@ void locked_publishPendingMsgs();
|
||||
uint16_t locked_determineCacheSubId();
|
||||
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
@ -366,6 +367,7 @@ virtual bool locked_choosePublishKey(GroupInfo &info);
|
||||
/* TO FINISH */
|
||||
/* utilities */
|
||||
std::string HashRsItem(const RsItem *item);
|
||||
bool locked_updateChildTS(GroupInfo &gi, RsDistribMsg *msg);
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
@ -165,6 +165,7 @@ bool p3Forums::getForumThreadList(std::string fId, std::list<ThreadInfoSummary>
|
||||
tis.threadId = msg->msgId; // these are the thread heads!
|
||||
|
||||
tis.ts = msg->timestamp;
|
||||
tis.childTS = msg->childTS;
|
||||
|
||||
/* the rest must be gotten from the derived Msg */
|
||||
|
||||
@ -200,6 +201,7 @@ bool p3Forums::getForumThreadMsgList(std::string fId, std::string pId, std::list
|
||||
tis.threadId = msg->threadId;
|
||||
|
||||
tis.ts = msg->timestamp;
|
||||
tis.childTS = msg->childTS;
|
||||
|
||||
/* the rest must be gotten from the derived Msg */
|
||||
|
||||
@ -230,6 +232,7 @@ bool p3Forums::getForumMessage(std::string fId, std::string mId, ForumMsgInfo &i
|
||||
info.threadId = msg->threadId;
|
||||
|
||||
info.ts = msg->timestamp;
|
||||
info.childTS = msg->childTS;
|
||||
|
||||
/* the rest must be gotten from the derived Msg */
|
||||
|
||||
@ -303,29 +306,6 @@ std::string p3Forums::createForumMsg(std::string fId, std::string pId,
|
||||
return msgId;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* p3Config Serialiser */
|
||||
RsSerialiser *p3Forums::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
|
||||
rss->addSerialType(new RsForumSerialiser());
|
||||
return rss;
|
||||
}
|
||||
|
||||
pqistreamer *p3Forums::createStreamer(BinInterface *bio, std::string src, uint32_t bioflags)
|
||||
{
|
||||
RsSerialiser *rsSerialiser = new RsSerialiser();
|
||||
//rsSerialiser->addSerialType(new RsForumSerialiser());
|
||||
rsSerialiser->addSerialType(new RsDistribSerialiser());
|
||||
|
||||
pqistreamer *streamer = new pqistreamer(rsSerialiser, src, bio, bioflags);
|
||||
return streamer;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
RsSerialType *p3Forums::createSerialiser()
|
||||
{
|
||||
return new RsForumSerialiser();
|
||||
|
Loading…
Reference in New Issue
Block a user