mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-10 10:05:19 -04:00
Merge pull request #1415 from csoler/v0.6.5-ForumModel2
V0.6.5 forum model2
This commit is contained in:
commit
9ce573c3f5
15 changed files with 2599 additions and 2564 deletions
|
@ -1714,10 +1714,11 @@ void RsGxsDataAccess::filterMsgList(
|
|||
|
||||
MsgMetaFilter::const_iterator cit = msgMetas.find(groupId);
|
||||
if(cit == msgMetas.end()) continue;
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << __PRETTY_FUNCTION__ << " " << msgsIdSet.size()
|
||||
<< " for group: " << groupId << " before filtering"
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
for( std::set<RsGxsMessageId>::iterator msgIdIt = msgsIdSet.begin();
|
||||
msgIdIt != msgsIdSet.end(); )
|
||||
|
@ -1738,9 +1739,11 @@ void RsGxsDataAccess::filterMsgList(
|
|||
else msgIdIt = msgsIdSet.erase(msgIdIt);
|
||||
}
|
||||
|
||||
#ifdef DATA_DEBUG
|
||||
std::cerr << __PRETTY_FUNCTION__ << " " << msgsIdSet.size()
|
||||
<< " for group: " << groupId << " after filtering"
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ static const uint32_t RS_GXS_FORUM_MSG_FLAGS_MODERATED = 0x00000001;
|
|||
|
||||
struct RsGxsForumGroup : RsSerializable
|
||||
{
|
||||
virtual ~RsGxsForumGroup() {}
|
||||
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mDescription;
|
||||
|
||||
|
@ -76,6 +78,8 @@ struct RsGxsForumGroup : RsSerializable
|
|||
|
||||
struct RsGxsForumMsg : RsSerializable
|
||||
{
|
||||
virtual ~RsGxsForumMsg() {}
|
||||
|
||||
RsMsgMetaData mMeta;
|
||||
std::string mMsg;
|
||||
|
||||
|
@ -139,10 +143,11 @@ public:
|
|||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumGroup>& forumsInfo ) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get content of specified forums. Blocking API
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumIds id of the channels of which the content is requested
|
||||
* @param[in] forumIds id of the forum of which the content is requested
|
||||
* @param[out] messages storage for the forum messages
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
|
@ -150,6 +155,29 @@ public:
|
|||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages ) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get message metadatas for some messages of a specific forum. Blocking API
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumIds id of the forum of which the content is requested
|
||||
* @param[out] msg_metas storage for the forum messages meta data
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getForumMsgMetaData( const RsGxsGroupId& forumId,
|
||||
std::vector<RsMsgMetaData>& msg_metas) =0;
|
||||
|
||||
/**
|
||||
* @brief Get specific list of messages from a single forums. Blocking API
|
||||
* @jsonapi{development}
|
||||
* @param[in] forumId id of the forum of which the content is requested
|
||||
* @param[in] msgs_to_request list of message ids to request
|
||||
* @param[out] msgs storage for the forum messages
|
||||
* @return false if something failed, true otherwhise
|
||||
*/
|
||||
virtual bool getForumsContent(
|
||||
const RsGxsGroupId& forumId,
|
||||
std::set<RsGxsMessageId>& msgs_to_request,
|
||||
std::vector<RsGxsForumMsg>& msgs) =0;
|
||||
|
||||
/**
|
||||
* @brief Toggle message read status. Blocking API.
|
||||
* @jsonapi{development}
|
||||
|
|
|
@ -61,6 +61,8 @@ struct RsGroupMetaData : RsSerializable
|
|||
mCircleType(0x0001), mAuthenFlags(0), mSubscribeFlags(0), mPop(0),
|
||||
mVisibleMsgCount(0), mLastPost(0), mGroupStatus(0) {}
|
||||
|
||||
virtual ~RsGroupMetaData() {}
|
||||
|
||||
void operator =(const RsGxsGrpMetaData& rGxsMeta);
|
||||
|
||||
RsGxsGroupId mGroupId;
|
||||
|
@ -124,9 +126,9 @@ struct RsMsgMetaData : RsSerializable
|
|||
{
|
||||
RsMsgMetaData() : mPublishTs(0), mMsgFlags(0), mMsgStatus(0), mChildTs(0) {}
|
||||
|
||||
virtual ~RsMsgMetaData() {}
|
||||
void operator =(const RsGxsMsgMetaData& rGxsMeta);
|
||||
|
||||
|
||||
RsGxsGroupId mGroupId;
|
||||
RsGxsMessageId mMsgId;
|
||||
|
||||
|
|
|
@ -297,6 +297,11 @@ bool p3GxsForums::getGroupData(const uint32_t &token, std::vector<RsGxsForumGrou
|
|||
return ok;
|
||||
}
|
||||
|
||||
bool p3GxsForums::getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas)
|
||||
{
|
||||
return RsGenExchange::getMsgMeta(token, msg_metas);
|
||||
}
|
||||
|
||||
/* Okay - chris is not going to be happy with this...
|
||||
* but I can't be bothered with crazy data structures
|
||||
* at the moment - fix it up later
|
||||
|
@ -389,7 +394,7 @@ bool p3GxsForums::createForum(RsGxsForumGroup& forum)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
|
@ -416,7 +421,7 @@ bool p3GxsForums::editForum(RsGxsForumGroup& forum)
|
|||
return false;
|
||||
}
|
||||
|
||||
if(waitToken(token) != RsTokenService::COMPLETE)
|
||||
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
|
||||
<< std::endl;
|
||||
|
@ -433,14 +438,13 @@ bool p3GxsForums::editForum(RsGxsForumGroup& forum)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsSummaries(
|
||||
std::list<RsGroupMetaData>& forums )
|
||||
bool p3GxsForums::getForumsSummaries( std::list<RsGroupMetaData>& forums )
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
if( !requestGroupInfo(token, opts)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
return getGroupSummary(token, forums);
|
||||
}
|
||||
|
||||
|
@ -452,10 +456,24 @@ bool p3GxsForums::getForumsInfo(
|
|||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
if( !requestGroupInfo(token, opts, forumIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
return getGroupData(token, forumsInfo);
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs)
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
msgIds[forumId] = msgs_to_request;
|
||||
|
||||
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
return getMsgData(token, msgs) ;
|
||||
}
|
||||
|
||||
bool p3GxsForums::getForumsContent(
|
||||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages )
|
||||
|
@ -464,15 +482,35 @@ bool p3GxsForums::getForumsContent(
|
|||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
if( !requestMsgInfo(token, opts, forumIds)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
return getMsgData(token, messages);
|
||||
}
|
||||
|
||||
|
||||
bool p3GxsForums::getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas)
|
||||
{
|
||||
uint32_t token;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_META;
|
||||
|
||||
GxsMsgMetaMap meta_map;
|
||||
std::list<RsGxsGroupId> forumIds;
|
||||
forumIds.push_back(forumId);
|
||||
|
||||
if( !requestMsgInfo(token, opts, forumIds) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
bool res = getMsgMetaData(token, meta_map);
|
||||
|
||||
msg_metas = meta_map[forumId];
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool p3GxsForums::markRead(const RsGxsGrpMsgIdPair& msgId, bool read)
|
||||
{
|
||||
uint32_t token;
|
||||
setMessageReadStatus(token, msgId, read);
|
||||
if(waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -517,7 +555,7 @@ bool p3GxsForums::createMessage(RsGxsForumMsg& message)
|
|||
{
|
||||
uint32_t token;
|
||||
if( !createMsg(token, message)
|
||||
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
|
||||
|
||||
if(RsGenExchange::getPublishedMsgMeta(token, message.mMeta)) return true;
|
||||
|
||||
|
|
|
@ -77,6 +77,12 @@ public:
|
|||
const std::list<RsGxsGroupId>& forumIds,
|
||||
std::vector<RsGxsForumMsg>& messages );
|
||||
|
||||
/// @see RsGxsForums::getForumMsgMetaData
|
||||
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
|
||||
|
||||
/// @see RsGxsForums::getForumsContent
|
||||
virtual bool getForumsContent( const RsGxsGroupId& forumId, std::set<RsGxsMessageId>& msgs_to_request,std::vector<RsGxsForumMsg>& msgs) ;
|
||||
|
||||
/// @see RsGxsForums::markRead
|
||||
virtual bool markRead(const RsGxsGrpMsgIdPair& messageId, bool read);
|
||||
|
||||
|
@ -86,6 +92,7 @@ public:
|
|||
|
||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups);
|
||||
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs);
|
||||
virtual bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas);
|
||||
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
|
||||
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group);
|
||||
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue