mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
* Added FlagFilter to TokenOptions.
* Added data to posted data * modified dummyData to have nested Comments. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5365 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3f5c96ab8a
commit
c3ea5cbab6
@ -73,7 +73,9 @@ class RsTokReqOptions
|
|||||||
RsTokReqOptions()
|
RsTokReqOptions()
|
||||||
{
|
{
|
||||||
mOptions = 0;
|
mOptions = 0;
|
||||||
mStatusFilter = 0; mStatusMask = 0; mSubscribeFilter = 0;
|
mStatusFilter = 0; mStatusMask = 0;
|
||||||
|
mFlagsFilter = 0; mFlagsMask = 0;
|
||||||
|
mSubscribeFilter = 0;
|
||||||
mBefore = 0; mAfter = 0;
|
mBefore = 0; mAfter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +86,10 @@ class RsTokReqOptions
|
|||||||
uint32_t mStatusFilter;
|
uint32_t mStatusFilter;
|
||||||
uint32_t mStatusMask;
|
uint32_t mStatusMask;
|
||||||
|
|
||||||
|
// MsgFlags or GroupsFlags, depends on Request.
|
||||||
|
uint32_t mFlagsFilter;
|
||||||
|
uint32_t mFlagsMask;
|
||||||
|
|
||||||
uint32_t mSubscribeFilter; // Only for Groups.
|
uint32_t mSubscribeFilter; // Only for Groups.
|
||||||
|
|
||||||
// Time range... again applied after Options.
|
// Time range... again applied after Options.
|
||||||
|
@ -77,6 +77,9 @@ class RsPostedPost: public RsPostedMsg
|
|||||||
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_POST;
|
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_POST;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string mLink;
|
||||||
|
std::string mNotes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -99,6 +102,8 @@ class RsPostedComment: public RsPostedMsg
|
|||||||
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_COMMENT;
|
mMeta.mMsgFlags = RSPOSTED_MSGTYPE_COMMENT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string mComment;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,6 +370,33 @@ static bool checkGroupFilter(const RsTokReqOptions &opts, const RsGroupMetaData
|
|||||||
statusMatch = true;
|
statusMatch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool flagsMatch = false;
|
||||||
|
if (opts.mFlagsMask)
|
||||||
|
{
|
||||||
|
// Exact Flags match required.
|
||||||
|
if ((opts.mFlagsMask & opts.mFlagsFilter) == (opts.mFlagsMask & group.mGroupFlags))
|
||||||
|
{
|
||||||
|
std::cerr << "checkGroupFilter() Accepting Group as Flags Match: ";
|
||||||
|
std::cerr << " Mask: " << opts.mFlagsMask << " FlagsFilter: " << opts.mFlagsFilter;
|
||||||
|
std::cerr << " GroupFlags: " << group.mGroupFlags << " GroupId: " << group.mGroupId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
flagsMatch = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "checkGroupFilter() Dropping Group due to !Flags Match ";
|
||||||
|
std::cerr << " Mask: " << opts.mFlagsMask << " FlagsFilter: " << opts.mFlagsFilter;
|
||||||
|
std::cerr << " GroupFlags: " << group.mGroupFlags << " GroupId: " << group.mGroupId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no status comparision,
|
||||||
|
flagsMatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool subMatch = false;
|
bool subMatch = false;
|
||||||
if (opts.mSubscribeFilter)
|
if (opts.mSubscribeFilter)
|
||||||
{
|
{
|
||||||
@ -397,7 +424,7 @@ static bool checkGroupFilter(const RsTokReqOptions &opts, const RsGroupMetaData
|
|||||||
subMatch = true;
|
subMatch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (statusMatch && subMatch);
|
return (statusMatch && flagsMatch && subMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -429,7 +456,35 @@ static bool checkMsgFilter(const RsTokReqOptions &opts, const RsMsgMetaData &msg
|
|||||||
// no status comparision,
|
// no status comparision,
|
||||||
statusMatch = true;
|
statusMatch = true;
|
||||||
}
|
}
|
||||||
return statusMatch;
|
|
||||||
|
bool flagsMatch = false;
|
||||||
|
if (opts.mFlagsMask)
|
||||||
|
{
|
||||||
|
// Exact Flags match required.
|
||||||
|
if ((opts.mFlagsMask & opts.mFlagsFilter) == (opts.mFlagsMask & msg.mMsgFlags))
|
||||||
|
{
|
||||||
|
std::cerr << "checkMsgFilter() Accepting Msg as Flags Match: ";
|
||||||
|
std::cerr << " Mask: " << opts.mFlagsMask << " FlagsFilter: " << opts.mFlagsFilter;
|
||||||
|
std::cerr << " MsgFlags: " << msg.mMsgFlags << " MsgId: " << msg.mMsgId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
flagsMatch = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "checkMsgFilter() Dropping Msg due to !Flags Match ";
|
||||||
|
std::cerr << " Mask: " << opts.mFlagsMask << " FlagsFilter: " << opts.mFlagsFilter;
|
||||||
|
std::cerr << " MsgFlags: " << msg.mMsgFlags << " MsgId: " << msg.mMsgId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no status comparision,
|
||||||
|
flagsMatch = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (statusMatch && flagsMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -687,6 +742,7 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
bool onlyLatestMsgs = false;
|
bool onlyLatestMsgs = false;
|
||||||
bool onlyAllVersions = false;
|
bool onlyAllVersions = false;
|
||||||
bool onlyChildMsgs = false;
|
bool onlyChildMsgs = false;
|
||||||
|
bool onlyThreadMsgs = false;
|
||||||
|
|
||||||
if (opts.mOptions & RS_TOKREQOPT_MSG_LATEST)
|
if (opts.mOptions & RS_TOKREQOPT_MSG_LATEST)
|
||||||
{
|
{
|
||||||
@ -708,6 +764,13 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
onlyChildMsgs = true;
|
onlyChildMsgs = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts.mOptions & RS_TOKREQOPT_MSG_THREAD)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsDataProxy::getMsgRelatedList() MSG_THREAD";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
onlyThreadMsgs = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (onlyAllVersions && onlyChildMsgs)
|
if (onlyAllVersions && onlyChildMsgs)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & PARENT)";
|
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & PARENT)";
|
||||||
@ -716,6 +779,14 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onlyAllVersions && onlyThreadMsgs)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (VERSIONS & THREAD)";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!onlyLatestMsgs) && onlyChildMsgs)
|
if ((!onlyLatestMsgs) && onlyChildMsgs)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & PARENT)";
|
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & PARENT)";
|
||||||
@ -724,9 +795,25 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((!onlyLatestMsgs) && onlyThreadMsgs)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (!LATEST & THREAD)";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyChildMsgs && onlyThreadMsgs)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsDataProxy::getMsgRelatedList() ERROR Incompatible FLAGS (PARENT & THREAD)";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FALL BACK OPTION */
|
/* FALL BACK OPTION */
|
||||||
if ((!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs))
|
if ((!onlyLatestMsgs) && (!onlyAllVersions) && (!onlyChildMsgs) && (!onlyThreadMsgs))
|
||||||
{
|
{
|
||||||
std::cerr << "GxsDataProxy::getMsgRelatedList() FALLBACK -> NO FLAGS -> JUST COPY";
|
std::cerr << "GxsDataProxy::getMsgRelatedList() FALLBACK -> NO FLAGS -> JUST COPY";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
@ -755,7 +842,7 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
|
|
||||||
if (onlyLatestMsgs)
|
if (onlyLatestMsgs)
|
||||||
{
|
{
|
||||||
if (onlyChildMsgs)
|
if (onlyChildMsgs || onlyThreadMsgs)
|
||||||
{
|
{
|
||||||
// RUN THROUGH ALL MSGS... in map origId -> TS.
|
// RUN THROUGH ALL MSGS... in map origId -> TS.
|
||||||
std::map<std::string, std::pair<std::string, time_t> > origMsgTs;
|
std::map<std::string, std::pair<std::string, time_t> > origMsgTs;
|
||||||
@ -763,16 +850,27 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
for(mit = mMsgMetaData.begin(); mit != mMsgMetaData.end(); mit++)
|
for(mit = mMsgMetaData.begin(); mit != mMsgMetaData.end(); mit++)
|
||||||
{
|
{
|
||||||
// skip msgs that aren't children.
|
// skip msgs that aren't children.
|
||||||
|
if (onlyChildMsgs)
|
||||||
|
{
|
||||||
if (mit->second.mParentId != origMsgId)
|
if (mit->second.mParentId != origMsgId)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else /* onlyThreadMsgs */
|
||||||
|
{
|
||||||
|
if (mit->second.mThreadId != (*it))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
oit = origMsgTs.find(mit->second.mOrigMsgId);
|
oit = origMsgTs.find(mit->second.mOrigMsgId);
|
||||||
bool addMsg = false;
|
bool addMsg = false;
|
||||||
if (oit == origMsgTs.end())
|
if (oit == origMsgTs.end())
|
||||||
{
|
{
|
||||||
std::cerr << "GxsDataProxy::getMsgList() Found New OrigMsgId: ";
|
std::cerr << "GxsDataProxy::getMsgRelatedList() Found New OrigMsgId: ";
|
||||||
std::cerr << mit->second.mOrigMsgId;
|
std::cerr << mit->second.mOrigMsgId;
|
||||||
std::cerr << " MsgId: " << mit->second.mMsgId;
|
std::cerr << " MsgId: " << mit->second.mMsgId;
|
||||||
std::cerr << " TS: " << mit->second.mPublishTs;
|
std::cerr << " TS: " << mit->second.mPublishTs;
|
||||||
@ -783,7 +881,7 @@ bool GxsDataProxy::getMsgRelatedList(uint32_t &token, const RsTokReqOptions &opt
|
|||||||
// check timestamps.
|
// check timestamps.
|
||||||
else if (oit->second.second < mit->second.mPublishTs)
|
else if (oit->second.second < mit->second.mPublishTs)
|
||||||
{
|
{
|
||||||
std::cerr << "GxsDataProxy::getMsgList() Found Later Msg. OrigMsgId: ";
|
std::cerr << "GxsDataProxy::getMsgRelatedList() Found Later Msg. OrigMsgId: ";
|
||||||
std::cerr << mit->second.mOrigMsgId;
|
std::cerr << mit->second.mOrigMsgId;
|
||||||
std::cerr << " MsgId: " << mit->second.mMsgId;
|
std::cerr << " MsgId: " << mit->second.mMsgId;
|
||||||
std::cerr << " TS: " << mit->second.mPublishTs;
|
std::cerr << " TS: " << mit->second.mPublishTs;
|
||||||
|
@ -953,8 +953,11 @@ std::ostream &operator<<(std::ostream &out, const RsPostedGroup &group)
|
|||||||
bool p3PostedService::generateDummyData()
|
bool p3PostedService::generateDummyData()
|
||||||
{
|
{
|
||||||
#define MAX_GROUPS 10 //100
|
#define MAX_GROUPS 10 //100
|
||||||
#define MAX_POSTS 100 //1000
|
#define MAX_POSTS 50 //1000
|
||||||
#define MAX_COMMENTS 5000 //10000
|
|
||||||
|
#define MAX_BASE_COMMENTS 1000 //10000
|
||||||
|
#define MAX_COMMENTS 4000 //10000
|
||||||
|
|
||||||
#define MAX_VOTES 10000 //10000
|
#define MAX_VOTES 10000 //10000
|
||||||
|
|
||||||
std::list<RsPostedGroup> mGroups;
|
std::list<RsPostedGroup> mGroups;
|
||||||
@ -1056,7 +1059,7 @@ bool p3PostedService::generateDummyData()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < MAX_COMMENTS; i++)
|
for(i = 0; i < MAX_BASE_COMMENTS; i++)
|
||||||
{
|
{
|
||||||
/* generate a base thread */
|
/* generate a base thread */
|
||||||
|
|
||||||
@ -1106,6 +1109,56 @@ bool p3PostedService::generateDummyData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for(i = 0; i < MAX_COMMENTS; i++)
|
||||||
|
{
|
||||||
|
/* generate a base thread */
|
||||||
|
|
||||||
|
/* rotate the Forum Groups Around, then pick one.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int rnd = (int) (RSRandom::random_f32() * 10.0);
|
||||||
|
|
||||||
|
for(j = 0; j < rnd; j++)
|
||||||
|
{
|
||||||
|
RsPostedComment head = mComments.front();
|
||||||
|
mComments.pop_front();
|
||||||
|
mComments.push_back(head);
|
||||||
|
}
|
||||||
|
|
||||||
|
RsPostedComment parent = mComments.front();
|
||||||
|
|
||||||
|
/* now create a new child msg */
|
||||||
|
|
||||||
|
RsPostedComment comment;
|
||||||
|
|
||||||
|
/* fill in key data
|
||||||
|
* GroupId
|
||||||
|
* MsgId
|
||||||
|
* OrigMsgId
|
||||||
|
* ThreadId
|
||||||
|
* ParentId
|
||||||
|
* PublishTS (take Forum TS + a bit ).
|
||||||
|
*
|
||||||
|
* ChildTS ????
|
||||||
|
*/
|
||||||
|
snprintf(name, DUMMY_NAME_MAX_LEN, "%s => Comment_%d", parent.mMeta.mMsgName.c_str(), i+1);
|
||||||
|
comment.mMeta.mMsgName = name;
|
||||||
|
//comment.mMsg = name;
|
||||||
|
|
||||||
|
comment.mMeta.mGroupId = parent.mMeta.mGroupId;
|
||||||
|
comment.mMeta.mMsgId = genRandomId();
|
||||||
|
comment.mMeta.mOrigMsgId = comment.mMeta.mMsgId;
|
||||||
|
comment.mMeta.mThreadId = parent.mMeta.mThreadId;
|
||||||
|
comment.mMeta.mParentId = parent.mMeta.mOrigMsgId;
|
||||||
|
|
||||||
|
comment.mMeta.mPublishTs = parent.mMeta.mPublishTs + (RSRandom::random_f32() * 10000);
|
||||||
|
if (comment.mMeta.mPublishTs > now)
|
||||||
|
comment.mMeta.mPublishTs = now - 1;
|
||||||
|
|
||||||
|
mComments.push_back(comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < MAX_VOTES; i++)
|
for(i = 0; i < MAX_VOTES; i++)
|
||||||
{
|
{
|
||||||
/* generate a base thread */
|
/* generate a base thread */
|
||||||
|
Loading…
Reference in New Issue
Block a user