Merge branch 'master' into thewire_fix_message_display

This commit is contained in:
drbob 2020-03-31 21:23:51 +11:00
commit 3402aa861f
119 changed files with 1809 additions and 1100 deletions

View file

@ -1033,18 +1033,35 @@ bool p3GxsChannels::getChannelsSummaries(
return getGroupSummary(token, channels);
}
bool p3GxsChannels::getChannelsInfo(
const std::list<RsGxsGroupId>& chanIds,
std::vector<RsGxsChannelGroup>& channelsInfo )
bool p3GxsChannels::getChannelsInfo( const std::list<RsGxsGroupId>& chanIds, std::vector<RsGxsChannelGroup>& channelsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, chanIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
if(chanIds.empty())
{
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
return false;
}
else
{
if( !requestGroupInfo(token, opts, chanIds) || waitToken(token) != RsTokenService::COMPLETE )
return false;
}
return getGroupData(token, channelsInfo) && !channelsInfo.empty();
}
bool p3GxsChannels::getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, channelId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsChannels::getContentSummaries(
const RsGxsGroupId& channelId, std::vector<RsMsgMetaData>& summaries )
{

View file

@ -140,7 +140,7 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
std::vector<RsGxsComment> &msgs ) override
{ return mCommentService->getGxsRelatedComments(token, msgs); }
virtual bool createNewComment(uint32_t &token, RsGxsComment &msg) override
virtual bool createNewComment(uint32_t &token, const RsGxsComment &msg) override
{
return mCommentService->createGxsComment(token, msg);
}
@ -196,6 +196,9 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
const RsGxsGroupId& channelId,
std::vector<RsMsgMetaData>& summaries ) override;
/// Implementation of @see RsGxsChannels::getChannelStatistics
bool getChannelStatistics(const RsGxsGroupId& channelId,GxsGroupStatistic& stat) override;
/// Implementation of @see RsGxsChannels::createChannelV2
bool createChannelV2(
const std::string& name, const std::string& description,
@ -277,7 +280,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
/// @deprecated Implementation of @see RsGxsChannels::createComment
RS_DEPRECATED_FOR(createCommentV2)
bool createComment(RsGxsComment& comment) override;
bool createComment(RsGxsComment &comment) override;
/// @deprecated Implementation of @see RsGxsChannels::createVote
RS_DEPRECATED_FOR(createVoteV2)

View file

@ -278,9 +278,13 @@ bool p3GxsCircles::getCirclesSummaries(std::list<RsGroupMetaData>& circles)
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token, opts)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupSummary(token, circles);
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
{
std::cerr << "Cannot get circles summary. Token queue is overloaded?" << std::endl;
return false;
}
else
return getGroupSummary(token, circles);
}
bool p3GxsCircles::getCirclesInfo( const std::list<RsGxsGroupId>& circlesIds,
@ -289,9 +293,13 @@ bool p3GxsCircles::getCirclesInfo( const std::list<RsGxsGroupId>& circlesIds,
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, circlesIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, circlesInfo);
if( !requestGroupInfo(token, opts, circlesIds) || waitToken(token) != RsTokenService::COMPLETE )
{
std::cerr << "Cannot get circle info. Token queue is overloaded?" << std::endl;
return false;
}
else
return getGroupData(token, circlesInfo);
}
bool p3GxsCircles::getCircleRequests( const RsGxsGroupId& circleId,

View file

@ -425,7 +425,7 @@ double p3GxsCommentService::calculateBestScore(int upVotes, int downVotes)
/********************************************************************************************/
bool p3GxsCommentService::createGxsComment(uint32_t &token, RsGxsComment &msg)
bool p3GxsCommentService::createGxsComment(uint32_t &token, const RsGxsComment &msg)
{
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::createGxsComment() GroupId: " << msg.mMeta.mGroupId;

View file

@ -66,7 +66,7 @@ class p3GxsCommentService: public GxsTokenQueue
bool getGxsCommentData(const uint32_t &token, std::vector<RsGxsComment> &msgs);
bool getGxsRelatedComments(const uint32_t &token, std::vector<RsGxsComment> &msgs);
bool createGxsComment(uint32_t &token, RsGxsComment &msg);
bool createGxsComment(uint32_t &token, const RsGxsComment &msg);
bool createGxsVote(uint32_t &token, RsGxsVote &msg);
// Special Acknowledge.

View file

@ -666,15 +666,22 @@ bool p3GxsForums::getForumsSummaries( std::list<RsGroupMetaData>& forums )
return getGroupSummary(token, forums);
}
bool p3GxsForums::getForumsInfo(
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo )
bool p3GxsForums::getForumsInfo( const std::list<RsGxsGroupId>& forumIds, std::vector<RsGxsForumGroup>& forumsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, forumIds)
|| waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE ) return false;
if(forumIds.empty())
{
if( !requestGroupInfo(token, opts) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE )
return false;
}
else
{
if( !requestGroupInfo(token, opts, forumIds, forumIds.size()==1) || waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE )
return false;
}
return getGroupData(token, forumsInfo);
}
@ -812,7 +819,16 @@ bool p3GxsForums::createGroup(uint32_t &token, RsGxsForumGroup &group)
return true;
}
bool p3GxsForums::updateGroup(uint32_t &token, RsGxsForumGroup &group)
bool p3GxsForums::getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, ForumId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3GxsForums::updateGroup(uint32_t &token, const RsGxsForumGroup &group)
{
std::cerr << "p3GxsForums::updateGroup()" << std::endl;

View file

@ -94,6 +94,9 @@ public:
const std::list<RsGxsGroupId>& forumIds,
std::vector<RsGxsForumGroup>& forumsInfo );
/// Implementation of @see RsGxsForums::getForumStatistics
bool getForumStatistics(const RsGxsGroupId& ForumId,GxsGroupStatistic& stat) override;
/// @see RsGxsForums::getForumMsgMetaData
virtual bool getForumMsgMetaData(const RsGxsGroupId& forumId, std::vector<RsMsgMetaData>& msg_metas) ;
@ -125,13 +128,16 @@ public:
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
) override;
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);
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group);
/// implementation of rsGxsGorums
///
bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) override;
bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) override;
void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override;
bool createGroup(uint32_t &token, RsGxsForumGroup &group) override;
bool createMsg(uint32_t &token, RsGxsForumMsg &msg) override;
bool updateGroup(uint32_t &token, const RsGxsForumGroup &group) override;
bool getMsgMetaData(const uint32_t &token, GxsMsgMetaMap& msg_metas) ;
private:

View file

@ -639,25 +639,28 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
std::cerr << std::endl;
#endif
if(!rsReputations->isIdentityBanned(RsGxsId(*git)))
{
uint32_t token;
RsGenExchange::subscribeToGroup(token, *git, true);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
// notify that a new identity is received, if needed
bool should_subscribe = false;
switch(groupChange->getType())
{
case RsGxsNotify::TYPE_PROCESSED: break ; // Happens when the group is subscribed. This is triggered by RsGenExchange::subscribeToGroup, so better not
// call it again from here!!
case RsGxsNotify::TYPE_PUBLISHED:
{
auto ev = std::make_shared<RsGxsIdentityEvent>();
ev->mIdentityId = *git;
ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY;
rsEvents->postEvent(ev);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
should_subscribe = true;
}
break;
@ -667,12 +670,23 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mIdentityId = *git;
ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY;
rsEvents->postEvent(ev);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
should_subscribe = true;
}
break;
default:
break;
}
if(should_subscribe)
{
uint32_t token;
RsGenExchange::subscribeToGroup(token, *git, true);
}
}
}
}

View file

@ -85,7 +85,7 @@ public:
return mCommentService->getGxsRelatedComments(token, msgs);
}
virtual bool createNewComment(uint32_t &token, RsGxsComment &msg) override
virtual bool createNewComment(uint32_t &token, const RsGxsComment &msg) override
{
return mCommentService->createGxsComment(token, msg);
}

View file

@ -307,8 +307,18 @@ bool p3Posted::getBoardsInfo(
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
if( !requestGroupInfo(token, opts, boardsIds)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
if(boardsIds.empty())
{
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE )
return false;
}
else
{
if( !requestGroupInfo(token, opts, boardsIds) || waitToken(token) != RsTokenService::COMPLETE )
return false;
}
return getGroupData(token, groupsInfo) && !groupsInfo.empty();
}
@ -330,5 +340,72 @@ bool p3Posted::getBoardContent( const RsGxsGroupId& groupId,
return getPostData(token, posts, comments);
}
bool p3Posted::getBoardsSummaries(std::list<RsGroupMetaData>& boards )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token, opts) || waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupSummary(token, boards);
}
bool p3Posted::getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat)
{
uint32_t token;
if(!RsGxsIfaceHelper::requestGroupStatistic(token, boardId) || waitToken(token) != RsTokenService::COMPLETE)
return false;
return RsGenExchange::getGroupStatistic(token,stat);
}
bool p3Posted::createBoard(RsPostedGroup& board)
{
uint32_t token;
if(!createGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating group." << std::endl;
return false;
}
if(waitToken(token,std::chrono::milliseconds(5000)) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
bool p3Posted::editBoard(RsPostedGroup& board)
{
uint32_t token;
if(!updateGroup(token, board))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed updating group." << std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed." << std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, board.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failure getting updated " << " group data." << std::endl;
return false;
}
return true;
}
RsPosted::~RsPosted() = default;
RsGxsPostedEvent::~RsGxsPostedEvent() = default;

View file

@ -66,6 +66,14 @@ virtual void receiveHelperChanges(std::vector<RsGxsNotify*>& changes)
std::vector<RsPostedPost>& posts,
std::vector<RsGxsComment>& comments ) override;
bool getBoardsSummaries(std::list<RsGroupMetaData>& groupInfo) override;
bool getBoardStatistics(const RsGxsGroupId& boardId,GxsGroupStatistic& stat) override;
bool editBoard(RsPostedGroup& board) override;
bool createBoard(RsPostedGroup& board) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsPostedGroup> &groups);
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; return getPostData( token, posts, cmts);}
@ -96,10 +104,16 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
std::vector<RsGxsComment> &msgs )
{ return mCommentService->getGxsRelatedComments(token, msgs); }
virtual bool createNewComment(uint32_t &token, RsGxsComment &msg)
virtual bool createNewComment(uint32_t &token, const RsGxsComment &msg) override
{
return mCommentService->createGxsComment(token, msg);
}
virtual bool createComment(RsGxsComment& msg) override
{
uint32_t token;
return mCommentService->createGxsComment(token, msg) && waitToken(token) == RsTokenService::COMPLETE ;
}
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg)
{