mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-17 20:04:22 -05:00
Merge pull request #1881 from PhenomRetroShare/Add_VotesOn_getPostData
Add Votes when calling getPostData.
This commit is contained in:
commit
2a5adddc3b
@ -314,7 +314,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool getChannelAllContent( const RsGxsGroupId& channelId,
|
virtual bool getChannelAllContent( const RsGxsGroupId& channelId,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get channel messages and comments corresponding to the given IDs.
|
* @brief Get channel messages and comments corresponding to the given IDs.
|
||||||
@ -326,12 +327,14 @@ public:
|
|||||||
* @param[in] contentsIds ids of requested contents
|
* @param[in] contentsIds ids of requested contents
|
||||||
* @param[out] posts storage for posts
|
* @param[out] posts storage for posts
|
||||||
* @param[out] comments storage for the comments
|
* @param[out] comments storage for the comments
|
||||||
|
* @param[out] votes storage for the votes
|
||||||
* @return false if something failed, true otherwhise
|
* @return false if something failed, true otherwhise
|
||||||
*/
|
*/
|
||||||
virtual bool getChannelContent( const RsGxsGroupId& channelId,
|
virtual bool getChannelContent( const RsGxsGroupId& channelId,
|
||||||
const std::set<RsGxsMessageId>& contentsIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get channel comments corresponding to the given IDs.
|
* @brief Get channel comments corresponding to the given IDs.
|
||||||
@ -571,6 +574,9 @@ public:
|
|||||||
RS_DEPRECATED_FOR(getChannelsInfo)
|
RS_DEPRECATED_FOR(getChannelsInfo)
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups) = 0;
|
||||||
|
|
||||||
|
RS_DEPRECATED_FOR(getChannelContent)
|
||||||
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts, std::vector<RsGxsVote> &votes) = 0;
|
||||||
|
|
||||||
RS_DEPRECATED_FOR(getChannelContent)
|
RS_DEPRECATED_FOR(getChannelContent)
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) = 0;
|
||||||
|
|
||||||
|
@ -154,13 +154,15 @@ public:
|
|||||||
virtual bool getBoardAllContent(
|
virtual bool getBoardAllContent(
|
||||||
const RsGxsGroupId& boardId,
|
const RsGxsGroupId& boardId,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) = 0;
|
||||||
|
|
||||||
virtual bool getBoardContent(
|
virtual bool getBoardContent(
|
||||||
const RsGxsGroupId& boardId,
|
const RsGxsGroupId& boardId,
|
||||||
const std::set<RsGxsMessageId>& contentsIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) = 0;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) = 0;
|
||||||
|
|
||||||
virtual bool editBoard(RsPostedGroup& board) =0;
|
virtual bool editBoard(RsPostedGroup& board) =0;
|
||||||
|
|
||||||
@ -176,6 +178,11 @@ public:
|
|||||||
virtual bool getGroupData( const uint32_t& token,
|
virtual bool getGroupData( const uint32_t& token,
|
||||||
std::vector<RsPostedGroup> &groups ) = 0;
|
std::vector<RsPostedGroup> &groups ) = 0;
|
||||||
|
|
||||||
|
RS_DEPRECATED_FOR(getBoardsContent)
|
||||||
|
virtual bool getPostData(
|
||||||
|
const uint32_t& token, std::vector<RsPostedPost>& posts,
|
||||||
|
std::vector<RsGxsComment>& cmts, std::vector<RsGxsVote>& vots) = 0;
|
||||||
|
|
||||||
RS_DEPRECATED_FOR(getBoardsContent)
|
RS_DEPRECATED_FOR(getBoardsContent)
|
||||||
virtual bool getPostData(
|
virtual bool getPostData(
|
||||||
const uint32_t& token, std::vector<RsPostedPost>& posts,
|
const uint32_t& token, std::vector<RsPostedPost>& posts,
|
||||||
|
@ -452,22 +452,23 @@ bool p3GxsChannels::groupShareKeys(
|
|||||||
|
|
||||||
bool p3GxsChannels::getPostData(
|
bool p3GxsChannels::getPostData(
|
||||||
const uint32_t &token, std::vector<RsGxsChannelPost> &msgs,
|
const uint32_t &token, std::vector<RsGxsChannelPost> &msgs,
|
||||||
std::vector<RsGxsComment> &cmts )
|
std::vector<RsGxsComment> &cmts,
|
||||||
|
std::vector<RsGxsVote> &vots)
|
||||||
{
|
{
|
||||||
#ifdef GXSCHANNELS_DEBUG
|
#ifdef GXSCHANNELS_DEBUG
|
||||||
std::cerr << __PRETTY_FUNCTION__ << std::cerr << std::endl;
|
RsDbg() << __PRETTY_FUNCTION__ << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
if(!RsGenExchange::getMsgData(token, msgData))
|
if(!RsGenExchange::getMsgData(token, msgData))
|
||||||
{
|
{
|
||||||
std::cerr << __PRETTY_FUNCTION__ <<" ERROR in request" << std::endl;
|
RsErr() << __PRETTY_FUNCTION__ << " ERROR in request" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsMsgDataMap::iterator mit = msgData.begin();
|
GxsMsgDataMap::iterator mit = msgData.begin();
|
||||||
|
|
||||||
for(; mit != msgData.end(); ++mit)
|
for(; mit != msgData.end(); ++mit)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||||
@ -495,7 +496,7 @@ bool p3GxsChannels::getPostData(
|
|||||||
cmt = cmtItem->mMsg;
|
cmt = cmtItem->mMsg;
|
||||||
cmt.mMeta = mi->meta;
|
cmt.mMeta = mi->meta;
|
||||||
#ifdef GXSCOMMENT_DEBUG
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
std::cerr << "p3GxsChannels::getPostData Found Comment:" << std::endl;
|
RsDbg() << __PRETTY_FUNCTION__ << " Found Comment:" << std::endl;
|
||||||
cmt.print(std::cerr," ", "cmt");
|
cmt.print(std::cerr," ", "cmt");
|
||||||
#endif
|
#endif
|
||||||
cmts.push_back(cmt);
|
cmts.push_back(cmt);
|
||||||
@ -503,18 +504,33 @@ bool p3GxsChannels::getPostData(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsGxsMsgItem* msg = (*vit);
|
RsGxsVoteItem* votItem =
|
||||||
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
dynamic_cast<RsGxsVoteItem*>(*vit);
|
||||||
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
if(votItem)
|
||||||
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
{
|
||||||
std::cerr << __PRETTY_FUNCTION__
|
RsGxsVote vot;
|
||||||
<< " Not a GxsChannelPostItem neither a "
|
RsGxsMsgItem *mi = (*vit);
|
||||||
<< "RsGxsCommentItem PacketService=" << std::hex
|
vot = votItem->mMsg;
|
||||||
<< (int)msg->PacketService() << std::dec
|
vot.mMeta = mi->meta;
|
||||||
<< " PacketSubType=" << std::hex
|
vots.push_back(vot);
|
||||||
<< (int)msg->PacketSubType() << std::dec
|
delete votItem;
|
||||||
<< " , deleting!" << std::endl;
|
}
|
||||||
delete *vit;
|
else
|
||||||
|
{
|
||||||
|
RsGxsMsgItem* msg = (*vit);
|
||||||
|
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
||||||
|
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
||||||
|
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
||||||
|
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM = 0xf2;
|
||||||
|
RsErr() << __PRETTY_FUNCTION__
|
||||||
|
<< " Not a GxsChannelPostItem neither a "
|
||||||
|
<< "RsGxsCommentItem neither a RsGxsVoteItem"
|
||||||
|
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
||||||
|
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
||||||
|
<< " type name =" << typeid(*msg).name()
|
||||||
|
<< " , deleting!" << std::endl;
|
||||||
|
delete *vit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,11 +539,19 @@ bool p3GxsChannels::getPostData(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3GxsChannels::getPostData(
|
||||||
|
const uint32_t& token, std::vector<RsGxsChannelPost>& posts, std::vector<RsGxsComment>& cmts )
|
||||||
|
{
|
||||||
|
std::vector<RsGxsVote> vots;
|
||||||
|
return getPostData(token, posts, cmts, vots);
|
||||||
|
}
|
||||||
|
|
||||||
bool p3GxsChannels::getPostData(
|
bool p3GxsChannels::getPostData(
|
||||||
const uint32_t& token, std::vector<RsGxsChannelPost>& posts )
|
const uint32_t& token, std::vector<RsGxsChannelPost>& posts )
|
||||||
{
|
{
|
||||||
std::vector<RsGxsComment> cmts;
|
std::vector<RsGxsComment> cmts;
|
||||||
return getPostData(token, posts, cmts);
|
std::vector<RsGxsVote> vots;
|
||||||
|
return getPostData(token, posts, cmts, vots);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not currently used
|
//Not currently used
|
||||||
@ -1091,22 +1115,24 @@ bool p3GxsChannels::getContentSummaries(
|
|||||||
|
|
||||||
bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
|
bool p3GxsChannels::getChannelAllContent( const RsGxsGroupId& channelId,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments )
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
if( !requestMsgInfo(token, opts,std::list<RsGxsGroupId>({channelId})) || waitToken(token) != RsTokenService::COMPLETE )
|
if( !requestMsgInfo(token, opts,std::list<RsGxsGroupId>({channelId})) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments,votes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
||||||
const std::set<RsGxsMessageId>& contentIds,
|
const std::set<RsGxsMessageId>& contentIds,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments )
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
@ -1118,7 +1144,7 @@ bool p3GxsChannels::getChannelContent( const RsGxsGroupId& channelId,
|
|||||||
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE )
|
if( !requestMsgInfo(token, opts, msgIds) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments, votes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsChannels::getChannelComments(const RsGxsGroupId &channelId,
|
bool p3GxsChannels::getChannelComments(const RsGxsGroupId &channelId,
|
||||||
@ -1293,8 +1319,9 @@ bool p3GxsChannels::createVoteV2(
|
|||||||
std::set<RsGxsMessageId> s({commentId});
|
std::set<RsGxsMessageId> s({commentId});
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(!getChannelContent(channelId, s, posts, comments))
|
if(!getChannelContent(channelId, s, posts, comments, votes))
|
||||||
{
|
{
|
||||||
errorMessage = "You cannot vote on comment "
|
errorMessage = "You cannot vote on comment "
|
||||||
+ commentId.toStdString() + " of channel with Id "
|
+ commentId.toStdString() + " of channel with Id "
|
||||||
@ -1454,8 +1481,9 @@ bool p3GxsChannels::createPostV2(
|
|||||||
std::set<RsGxsMessageId> s({origPostId});
|
std::set<RsGxsMessageId> s({origPostId});
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(!getChannelContent(channelId,s,posts,comments))
|
if(!getChannelContent(channelId,s,posts,comments,votes))
|
||||||
{
|
{
|
||||||
errorMessage = "You cannot edit post " + origPostId.toStdString()
|
errorMessage = "You cannot edit post " + origPostId.toStdString()
|
||||||
+ " of channel with Id " + channelId.toStdString()
|
+ " of channel with Id " + channelId.toStdString()
|
||||||
@ -1525,9 +1553,11 @@ bool p3GxsChannels::createCommentV2(
|
|||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(!getChannelContent( // does the post thread exist?
|
if(!getChannelContent( // does the post thread exist?
|
||||||
channelId,std::set<RsGxsMessageId>({threadId}), posts, comments ))
|
channelId, std::set<RsGxsMessageId>({threadId}),
|
||||||
|
posts, comments, votes) )
|
||||||
return failure( "You cannot comment post " + threadId.toStdString() +
|
return failure( "You cannot comment post " + threadId.toStdString() +
|
||||||
" of channel with Id " + channelId.toStdString() +
|
" of channel with Id " + channelId.toStdString() +
|
||||||
": this post does not exists locally!" );
|
": this post does not exists locally!" );
|
||||||
@ -1539,19 +1569,18 @@ bool p3GxsChannels::createCommentV2(
|
|||||||
": supplied threadId is not a thread, or parentMsgId is"
|
": supplied threadId is not a thread, or parentMsgId is"
|
||||||
" not a comment!");
|
" not a comment!");
|
||||||
|
|
||||||
if(!getChannelContent( // does the post thread exist?
|
if(!getChannelContent( // does the post parent exist?
|
||||||
channelId, std::set<RsGxsMessageId>({parentId}),
|
channelId, std::set<RsGxsMessageId>({parentId}),
|
||||||
posts, comments ))
|
posts, comments, votes) )
|
||||||
return failure( "You cannot comment post " + parentId.toStdString() +
|
return failure( "You cannot comment post " + parentId.toStdString() +
|
||||||
": supplied parent doesn't exists locally!" );
|
": supplied parent doesn't exists locally!" );
|
||||||
|
|
||||||
if(!origCommentId.isNull())
|
if(!origCommentId.isNull())
|
||||||
{
|
{
|
||||||
std::set<RsGxsMessageId> s({origCommentId});
|
std::set<RsGxsMessageId> s({origCommentId});
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsComment> cmts;
|
||||||
std::vector<RsGxsComment> comments;
|
|
||||||
|
|
||||||
if( !getChannelContent(channelId, s, posts, comments) ||
|
if( !getChannelContent(channelId, s, posts, cmts, votes) ||
|
||||||
comments.size() != 1 )
|
comments.size() != 1 )
|
||||||
return failure( "You cannot edit comment " +
|
return failure( "You cannot edit comment " +
|
||||||
origCommentId.toStdString() +
|
origCommentId.toStdString() +
|
||||||
|
@ -82,9 +82,10 @@ virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups);
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsChannelGroup> &groups ) override;
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts);
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts, std::vector<RsGxsVote> &vots) override;
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts, std::vector<RsGxsComment> &cmts) override;
|
||||||
|
virtual bool getPostData(const uint32_t &token, std::vector<RsGxsChannelPost> &posts) override;
|
||||||
//Not currently used
|
//Not currently used
|
||||||
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
|
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsGxsChannelPost> &posts);
|
||||||
|
|
||||||
@ -187,14 +188,16 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
|
|||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::getChannelAllMessages
|
/// Implementation of @see RsGxsChannels::getChannelAllMessages
|
||||||
bool getChannelAllContent(const RsGxsGroupId& channelId,
|
bool getChannelAllContent(const RsGxsGroupId& channelId,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) override;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) override;
|
||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::getChannelMessages
|
/// Implementation of @see RsGxsChannels::getChannelMessages
|
||||||
bool getChannelContent(const RsGxsGroupId& channelId,
|
bool getChannelContent(const RsGxsGroupId& channelId,
|
||||||
const std::set<RsGxsMessageId>& contentIds,
|
const std::set<RsGxsMessageId>& contentIds,
|
||||||
std::vector<RsGxsChannelPost>& posts,
|
std::vector<RsGxsChannelPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) override;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) override;
|
||||||
|
|
||||||
/// Implementation of @see RsGxsChannels::getChannelComments
|
/// Implementation of @see RsGxsChannels::getChannelComments
|
||||||
virtual bool getChannelComments(const RsGxsGroupId &channelId,
|
virtual bool getChannelComments(const RsGxsGroupId &channelId,
|
||||||
|
@ -94,55 +94,75 @@ bool p3Posted::getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &g
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msgs, std::vector<RsGxsComment> &cmts)
|
bool p3Posted::getPostData(
|
||||||
|
const uint32_t &token, std::vector<RsPostedPost> &msgs,
|
||||||
|
std::vector<RsGxsComment> &cmts,
|
||||||
|
std::vector<RsGxsVote> &vots)
|
||||||
{
|
{
|
||||||
#ifdef POSTED_DEBUG
|
#ifdef POSTED_DEBUG
|
||||||
std::cerr << "p3Posted::getPostData()";
|
RsDbg() << __PRETTY_FUNCTION__ << std::endl;
|
||||||
std::cerr << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GxsMsgDataMap msgData;
|
GxsMsgDataMap msgData;
|
||||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
|
||||||
rstime_t now = time(NULL);
|
rstime_t now = time(NULL);
|
||||||
|
if(!RsGenExchange::getMsgData(token, msgData))
|
||||||
if(ok)
|
|
||||||
{
|
{
|
||||||
GxsMsgDataMap::iterator mit = msgData.begin();
|
RsErr() << __PRETTY_FUNCTION__ << " ERROR in request" << std::endl;
|
||||||
|
return false;
|
||||||
for(; mit != msgData.end(); ++mit)
|
}
|
||||||
|
|
||||||
|
GxsMsgDataMap::iterator mit = msgData.begin();
|
||||||
|
|
||||||
|
for(; mit != msgData.end(); ++mit)
|
||||||
|
{
|
||||||
|
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||||
|
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||||
|
|
||||||
|
for(; vit != msgItems.end(); ++vit)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
RsGxsPostedPostItem* postItem =
|
||||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
dynamic_cast<RsGxsPostedPostItem*>(*vit);
|
||||||
|
|
||||||
for(; vit != msgItems.end(); ++vit)
|
if(postItem)
|
||||||
{
|
{
|
||||||
RsGxsPostedPostItem* postItem = dynamic_cast<RsGxsPostedPostItem*>(*vit);
|
// TODO Really needed all of these lines?
|
||||||
|
RsPostedPost msg = postItem->mPost;
|
||||||
|
msg.mMeta = postItem->meta;
|
||||||
|
postItem->toPostedPost(msg, true);
|
||||||
|
msg.calculateScores(now);
|
||||||
|
|
||||||
if(postItem)
|
msgs.push_back(msg);
|
||||||
|
delete postItem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RsGxsCommentItem* cmtItem =
|
||||||
|
dynamic_cast<RsGxsCommentItem*>(*vit);
|
||||||
|
if(cmtItem)
|
||||||
{
|
{
|
||||||
RsPostedPost msg = postItem->mPost;
|
RsGxsComment cmt;
|
||||||
msg.mMeta = postItem->meta;
|
RsGxsMsgItem *mi = (*vit);
|
||||||
postItem->toPostedPost(msg, true);
|
cmt = cmtItem->mMsg;
|
||||||
msg.calculateScores(now);
|
cmt.mMeta = mi->meta;
|
||||||
|
#ifdef GXSCOMMENT_DEBUG
|
||||||
msgs.push_back(msg);
|
RsDbg() << __PRETTY_FUNCTION__ << " Found Comment:" << std::endl;
|
||||||
delete postItem;
|
cmt.print(std::cerr," ", "cmt");
|
||||||
|
#endif
|
||||||
|
cmts.push_back(cmt);
|
||||||
|
delete cmtItem;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RsGxsCommentItem* cmtItem = dynamic_cast<RsGxsCommentItem*>(*vit);
|
RsGxsVoteItem* votItem =
|
||||||
if(cmtItem)
|
dynamic_cast<RsGxsVoteItem*>(*vit);
|
||||||
|
if(votItem)
|
||||||
{
|
{
|
||||||
RsGxsComment cmt;
|
RsGxsVote vot;
|
||||||
RsGxsMsgItem *mi = (*vit);
|
RsGxsMsgItem *mi = (*vit);
|
||||||
cmt = cmtItem->mMsg;
|
vot = votItem->mMsg;
|
||||||
cmt.mMeta = mi->meta;
|
vot.mMeta = mi->meta;
|
||||||
#ifdef GXSCOMMENT_DEBUG
|
vots.push_back(vot);
|
||||||
std::cerr << "p3Posted::getPostData Found Comment:" << std::endl;
|
delete votItem;
|
||||||
cmt.print(std::cerr," ", "cmt");
|
|
||||||
#endif
|
|
||||||
cmts.push_back(cmt);
|
|
||||||
delete cmtItem;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -150,24 +170,37 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msg
|
|||||||
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
//const uint16_t RS_SERVICE_GXS_TYPE_CHANNELS = 0x0217;
|
||||||
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
//const uint8_t RS_PKT_SUBTYPE_GXSCHANNEL_POST_ITEM = 0x03;
|
||||||
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_COMMENT_ITEM = 0xf1;
|
||||||
std::cerr << "Not a PostedPostItem neither a RsGxsCommentItem"
|
//const uint8_t RS_PKT_SUBTYPE_GXSCOMMENT_VOTE_ITEM = 0xf2;
|
||||||
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
RsErr() << __PRETTY_FUNCTION__
|
||||||
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
<< "Not a PostedPostItem neither a "
|
||||||
<< " type name =" << typeid(*msg).name()
|
<< "RsGxsCommentItem neither a RsGxsVoteItem"
|
||||||
<< " , deleting!" << std::endl;
|
<< " PacketService=" << std::hex << (int)msg->PacketService() << std::dec
|
||||||
|
<< " PacketSubType=" << std::hex << (int)msg->PacketSubType() << std::dec
|
||||||
|
<< " type name =" << typeid(*msg).name()
|
||||||
|
<< " , deleting!" << std::endl;
|
||||||
delete *vit;
|
delete *vit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "p3GxsChannels::getPostData() ERROR in request";
|
|
||||||
std::cerr << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ok;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3Posted::getPostData(
|
||||||
|
const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts)
|
||||||
|
{
|
||||||
|
std::vector<RsGxsVote> vots;
|
||||||
|
return getPostData( token, posts, cmts, vots);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3Posted::getPostData(
|
||||||
|
const uint32_t &token, std::vector<RsPostedPost> &posts)
|
||||||
|
{
|
||||||
|
std::vector<RsGxsComment> cmts;
|
||||||
|
std::vector<RsGxsVote> vots;
|
||||||
|
return getPostData( token, posts, cmts, vots);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not currently used
|
//Not currently used
|
||||||
@ -323,23 +356,25 @@ bool p3Posted::getBoardsInfo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::getBoardAllContent( const RsGxsGroupId& groupId,
|
bool p3Posted::getBoardAllContent( const RsGxsGroupId& groupId,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments )
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||||
|
|
||||||
if( !requestMsgInfo(token, opts, std::list<RsGxsGroupId>({groupId})) || waitToken(token) != RsTokenService::COMPLETE )
|
if( !requestMsgInfo(token, opts, std::list<RsGxsGroupId>({groupId})) || waitToken(token) != RsTokenService::COMPLETE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments, votes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
||||||
const std::set<RsGxsMessageId>& contentsIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments )
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes )
|
||||||
{
|
{
|
||||||
uint32_t token;
|
uint32_t token;
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
@ -351,7 +386,7 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
|
|||||||
if( !requestMsgInfo(token, opts, msgIds) ||
|
if( !requestMsgInfo(token, opts, msgIds) ||
|
||||||
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
waitToken(token) != RsTokenService::COMPLETE ) return false;
|
||||||
|
|
||||||
return getPostData(token, posts, comments);
|
return getPostData(token, posts, comments, votes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
|
bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
|
||||||
|
@ -64,13 +64,15 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
std::vector<RsPostedGroup>& groupsInfo ) override;
|
std::vector<RsPostedGroup>& groupsInfo ) override;
|
||||||
|
|
||||||
bool getBoardAllContent(const RsGxsGroupId& groupId,
|
bool getBoardAllContent(const RsGxsGroupId& groupId,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) override;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) override;
|
||||||
|
|
||||||
bool getBoardContent(const RsGxsGroupId& groupId,
|
bool getBoardContent(const RsGxsGroupId& groupId,
|
||||||
const std::set<RsGxsMessageId>& contentsIds,
|
const std::set<RsGxsMessageId>& contentsIds,
|
||||||
std::vector<RsPostedPost>& posts,
|
std::vector<RsPostedPost>& posts,
|
||||||
std::vector<RsGxsComment>& comments ) override;
|
std::vector<RsGxsComment>& comments,
|
||||||
|
std::vector<RsGxsVote>& votes ) override;
|
||||||
|
|
||||||
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
|
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
|
||||||
|
|
||||||
@ -82,9 +84,10 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
|
|||||||
|
|
||||||
bool createBoard(RsPostedGroup& board) override;
|
bool createBoard(RsPostedGroup& board) override;
|
||||||
|
|
||||||
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
|
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups) override;
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts);
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts, std::vector<RsGxsVote> &vots) override;
|
||||||
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) { std::vector<RsGxsComment> cmts; return getPostData( token, posts, cmts);}
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts, std::vector<RsGxsComment> &cmts) override;
|
||||||
|
virtual bool getPostData(const uint32_t &token, std::vector<RsPostedPost> &posts) override;
|
||||||
//Not currently used
|
//Not currently used
|
||||||
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
|
//virtual bool getRelatedPosts(const uint32_t &token, std::vector<RsPostedPost> &posts);
|
||||||
|
|
||||||
|
@ -167,8 +167,9 @@ void BasePostedItem::loadMessage()
|
|||||||
|
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
if(! rsPosted->getBoardContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "BasePostedItem::loadMessage() ERROR getting data" << std::endl;
|
RsErr() << "BasePostedItem::loadMessage() ERROR getting data" << std::endl;
|
||||||
mIsLoadingMessage = false;
|
mIsLoadingMessage = false;
|
||||||
@ -227,8 +228,9 @@ void BasePostedItem::loadComment()
|
|||||||
|
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments))
|
if(! rsPosted->getBoardContent( groupId(),msgIds,posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "BasePostedItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "BasePostedItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
mIsLoadingComment = false;
|
mIsLoadingComment = false;
|
||||||
|
@ -1033,8 +1033,9 @@ void PostedListWidget::getMsgData(const std::set<RsGxsMessageId>& msgIds,std::ve
|
|||||||
{
|
{
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
rsPosted->getBoardContent( groupId(),msgIds,posts,comments );
|
rsPosted->getBoardContent( groupId(),msgIds,posts,comments,votes );
|
||||||
|
|
||||||
psts.clear();
|
psts.clear();
|
||||||
|
|
||||||
@ -1046,8 +1047,9 @@ void PostedListWidget::getAllMsgData(std::vector<RsGxsGenericMsgData*>& psts)
|
|||||||
{
|
{
|
||||||
std::vector<RsPostedPost> posts;
|
std::vector<RsPostedPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
rsPosted->getBoardAllContent( groupId(),posts,comments );
|
rsPosted->getBoardAllContent( groupId(),posts,comments,votes );
|
||||||
|
|
||||||
psts.clear();
|
psts.clear();
|
||||||
|
|
||||||
|
@ -319,8 +319,9 @@ void GxsChannelPostItem::loadMessage()
|
|||||||
|
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments))
|
if(! rsGxsChannels->getChannelContent( groupId(), std::set<RsGxsMessageId>( { messageId() } ),posts,comments,votes))
|
||||||
{
|
{
|
||||||
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
RsErr() << "GxsGxsChannelGroupItem::loadGroup() ERROR getting data" << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -738,14 +738,15 @@ void CreateGxsChannelMsg::loadOriginalChannelPostInfo()
|
|||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
if( !rsGxsChannels->getChannelContent(mChannelId,std::set<RsGxsMessageId>({mOrigPostId}),posts,comments) || posts.size() != 1)
|
if( !rsGxsChannels->getChannelContent(mChannelId,std::set<RsGxsMessageId>({mOrigPostId}),posts,comments,votes) || posts.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "Cannot get channel post data for channel " << mChannelId << " and post " << mOrigPostId << std::endl;
|
std::cerr << "Cannot get channel post data for channel " << mChannelId << " and post " << mOrigPostId << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RsQThreadUtils::postToObject( [posts,this]()
|
RsQThreadUtils::postToObject( [posts,this]()
|
||||||
{
|
{
|
||||||
/* Here it goes any code you want to be executed on the Qt Gui
|
/* Here it goes any code you want to be executed on the Qt Gui
|
||||||
* thread, for example to update the data model with new information
|
* thread, for example to update the data model with new information
|
||||||
|
@ -694,7 +694,7 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost>& po
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
thread->emitAddPost(qVariantFromValue(*it), related, ++pos, count);
|
thread->emitAddPost(QVariant::fromValue(*it), related, ++pos, count);
|
||||||
else
|
else
|
||||||
createPostItem(*it, related);
|
createPostItem(*it, related);
|
||||||
}
|
}
|
||||||
@ -812,8 +812,9 @@ void GxsChannelPostsWidget::getMsgData(const std::set<RsGxsMessageId>& msgIds,st
|
|||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments );
|
rsGxsChannels->getChannelContent( groupId(),msgIds,posts,comments,votes );
|
||||||
|
|
||||||
psts.clear();
|
psts.clear();
|
||||||
|
|
||||||
@ -825,8 +826,9 @@ void GxsChannelPostsWidget::getAllMsgData(std::vector<RsGxsGenericMsgData*>& pst
|
|||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost> posts;
|
std::vector<RsGxsChannelPost> posts;
|
||||||
std::vector<RsGxsComment> comments;
|
std::vector<RsGxsComment> comments;
|
||||||
|
std::vector<RsGxsVote> votes;
|
||||||
|
|
||||||
rsGxsChannels->getChannelAllContent( groupId(),posts,comments );
|
rsGxsChannels->getChannelAllContent( groupId(),posts,comments,votes );
|
||||||
|
|
||||||
psts.clear();
|
psts.clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user