fixed merge upstream/master

This commit is contained in:
csoler 2019-03-24 20:59:23 +01:00
commit d2c15c2d9e
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
155 changed files with 4204 additions and 2522 deletions

View file

@ -1089,7 +1089,7 @@ bool p3GxsChannels::createChannel(RsGxsChannelGroup& channel)
bool p3GxsChannels::createComment(RsGxsComment& comment)
{
uint32_t token;
if(!createComment(token, comment))
if(!createNewComment(token, comment))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating comment."
<< std::endl;
@ -1116,7 +1116,7 @@ bool p3GxsChannels::createComment(RsGxsComment& comment)
bool p3GxsChannels::createVote(RsGxsVote& vote)
{
uint32_t token;
if(!createVote(token, vote))
if(!createNewVote(token, vote))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed creating vote."
<< std::endl;
@ -1795,7 +1795,7 @@ bool p3GxsChannels::generateComment(uint32_t &token, const RsGxsGroupId &grpId,
}
#endif
createComment(token, msg);
createNewComment(token, msg);
return true;
}
@ -1846,7 +1846,7 @@ bool p3GxsChannels::generateVote(uint32_t &token, const RsGxsGroupId &grpId, con
vote.mVoteType = GXS_VOTE_DOWN;
}
createVote(token, vote);
createNewVote(token, vote);
return true;
}

View file

@ -132,30 +132,29 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
const RsGxsGroupId& grpId ) override;
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs)
virtual bool getCommentData(uint32_t token, std::vector<RsGxsComment> &msgs) override
{ return mCommentService->getGxsCommentData(token, msgs); }
virtual bool getRelatedComments( uint32_t token,
std::vector<RsGxsComment> &msgs )
std::vector<RsGxsComment> &msgs ) override
{ return mCommentService->getGxsRelatedComments(token, msgs); }
virtual bool createComment(uint32_t &token, RsGxsComment &msg)
virtual bool createNewComment(uint32_t &token, RsGxsComment &msg) override
{
return mCommentService->createGxsComment(token, msg);
}
virtual bool createVote(uint32_t &token, RsGxsVote &msg)
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg) override
{
return mCommentService->createGxsVote(token, msg);
}
virtual bool acknowledgeComment(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
virtual bool acknowledgeComment(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) override
{
return acknowledgeMsg(token, msgId);
}
virtual bool acknowledgeVote(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId)
virtual bool acknowledgeVote(uint32_t token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) override
{
if (mCommentService->acknowledgeVote(token, msgId))
{

View file

@ -153,7 +153,118 @@ RsServiceInfo p3GxsCircles::getServiceInfo()
GXS_CIRCLES_MIN_MINOR_VERSION);
}
bool p3GxsCircles::createCircle(RsGxsCircleGroup& cData)
{
uint32_t token;
createGroup(token, cData);
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, cData.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting created"
<< " group data." << std::endl;
return false;
}
return true;
}
bool p3GxsCircles::editCircle(RsGxsCircleGroup& cData)
{
uint32_t token;
updateGroup(token, cData);
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
if(!RsGenExchange::getPublishedGroupMeta(token, cData.mMeta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated"
<< " group data." << std::endl;
return false;
}
return true;
}
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);
}
bool p3GxsCircles::getCirclesInfo( const std::list<RsGxsGroupId>& circlesIds,
std::vector<RsGxsCircleGroup>& circlesInfo )
{
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);
}
bool p3GxsCircles::getCircleRequests( const RsGxsGroupId& circleId,
std::vector<RsGxsCircleMsg>& requests )
{
uint32_t token;
std::list<RsGxsGroupId> grpIds { circleId };
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
if( !requestMsgInfo(token, opts, grpIds) ||
waitToken(token) != RsTokenService::COMPLETE ) return false;
return getMsgData(token, requests);
}
bool p3GxsCircles::inviteIdsToCircle( const std::set<RsGxsId>& identities,
const RsGxsCircleId& circleId )
{
const std::list<RsGxsGroupId> circlesIds{ RsGxsGroupId(circleId) };
std::vector<RsGxsCircleGroup> circlesInfo;
if(!getCirclesInfo(circlesIds, circlesInfo))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting group data."
<< std::endl;
return false;
}
if(circlesInfo.empty())
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Circle: "
<< circleId.toStdString() << " not found!" << std::endl;
return false;
}
RsGxsCircleGroup& circleGrp = circlesInfo[0];
if(!(circleGrp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Attempt to edit non-own "
<< "circle: " << circleId.toStdString() << std::endl;
return false;
}
circleGrp.mInvitedMembers.insert(identities.begin(), identities.end());
return editCircle(circleGrp);
}
uint32_t p3GxsCircles::circleAuthenPolicy()
{
@ -320,32 +431,6 @@ bool p3GxsCircles:: getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails
return false;
}
bool p3GxsCircles:: getCirclePersonalIdList(std::list<RsGxsCircleId> &circleIds)
{
#ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::getCircleIdList()";
std::cerr << std::endl;
#endif // DEBUG_CIRCLES
RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/
if (circleIds.empty())
{
circleIds = mCirclePersonalIdList;
}
else
{
std::list<RsGxsCircleId>::const_iterator it;
for(it = mCirclePersonalIdList.begin(); it != mCirclePersonalIdList.begin(); ++it)
{
circleIds.push_back(*it);
}
}
return true;
}
bool p3GxsCircles:: getCircleExternalIdList(std::list<RsGxsCircleId> &circleIds)
{
#ifdef DEBUG_CIRCLES

View file

@ -179,9 +179,30 @@ virtual RsServiceInfo getServiceInfo();
/*********** External Interface ***************/
/// @see RsGxsCircles
bool createCircle(RsGxsCircleGroup& cData) override;
/// @see RsGxsCircles
bool editCircle(RsGxsCircleGroup& cData) override;
/// @see RsGxsCircles
bool getCirclesSummaries(std::list<RsGroupMetaData>& circles) override;
/// @see RsGxsCircles
bool getCirclesInfo(
const std::list<RsGxsGroupId>& circlesIds,
std::vector<RsGxsCircleGroup>& circlesInfo ) override;
/// @see RsGxsCircles
bool getCircleRequests( const RsGxsGroupId& circleId,
std::vector<RsGxsCircleMsg>& requests ) override;
/// @see RsGxsCircles
bool inviteIdsToCircle( const std::set<RsGxsId>& identities,
const RsGxsCircleId& circleId ) override;
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details);
virtual bool getCircleExternalIdList(std::list<RsGxsCircleId> &circleIds);
virtual bool getCirclePersonalIdList(std::list<RsGxsCircleId> &circleIds);
virtual bool isLoaded(const RsGxsCircleId &circleId);
virtual bool loadCircle(const RsGxsCircleId &circleId);
@ -257,6 +278,8 @@ virtual RsServiceInfo getServiceInfo();
// put a circle id into the external or personal circle id list
// this function locks the mutex
// if the id is already in the list, it will not be added again
// G10h4ck: this is terrible, an std::set instead of a list should be used
// to guarantee uniqueness
void addCircleIdToList(const RsGxsCircleId& circleId, uint32_t circleType);
RsMutex mCircleMtx; /* Locked Below Here */

View file

@ -236,7 +236,7 @@ int p3GxsReputation::tick()
return 0;
}
void p3GxsReputation::setNodeAutoPositiveOpinionForContacts(bool b)
void p3GxsReputation::setAutoPositiveOpinionForContacts(bool b)
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
@ -249,13 +249,13 @@ void p3GxsReputation::setNodeAutoPositiveOpinionForContacts(bool b)
IndicateConfigChanged() ;
}
}
bool p3GxsReputation::nodeAutoPositiveOpinionForContacts()
bool p3GxsReputation::autoPositiveOpinionForContacts()
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
return mAutoSetPositiveOptionToContacts ;
}
void p3GxsReputation::setRememberDeletedNodesThreshold(uint32_t days)
void p3GxsReputation::setRememberBannedIdThreshold(uint32_t days)
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
@ -265,7 +265,7 @@ void p3GxsReputation::setRememberDeletedNodesThreshold(uint32_t days)
IndicateConfigChanged();
}
}
uint32_t p3GxsReputation::rememberDeletedNodesThreshold()
uint32_t p3GxsReputation::rememberBannedIdThreshold()
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
@ -382,7 +382,10 @@ void p3GxsReputation::cleanup()
{
bool should_delete = false ;
if(it->second.mOwnOpinion == RsReputations::OPINION_NEGATIVE && mMaxPreventReloadBannedIds != 0 && it->second.mOwnOpinionTs + mMaxPreventReloadBannedIds < now)
if( it->second.mOwnOpinion ==
static_cast<int32_t>(RsOpinion::NEGATIVE) &&
mMaxPreventReloadBannedIds != 0 &&
it->second.mOwnOpinionTs + mMaxPreventReloadBannedIds < now )
{
#ifdef DEBUG_REPUTATION
std::cerr << " ID " << it->first << ": own is negative for more than " << mMaxPreventReloadBannedIds/86400 << " days. Reseting it!" << std::endl;
@ -392,7 +395,10 @@ void p3GxsReputation::cleanup()
// Delete slots with basically no information
if(it->second.mOpinions.empty() && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL && (it->second.mOwnerNode.isNull()))
if( it->second.mOpinions.empty() &&
it->second.mOwnOpinion ==
static_cast<int32_t>(RsOpinion::NEUTRAL) &&
it->second.mOwnerNode.isNull() )
{
#ifdef DEBUG_REPUTATION
std::cerr << " ID " << it->first << ": own is neutral and no opinions from friends => remove entry" << std::endl;
@ -461,23 +467,20 @@ void p3GxsReputation::cleanup()
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();++it)
if(it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
if( it->second.mOwnOpinion ==
static_cast<int32_t>(RsOpinion::NEUTRAL) )
should_set_to_positive_candidates.push_back(it->first) ;
}
for(std::list<RsGxsId>::const_iterator it(should_set_to_positive_candidates.begin());it!=should_set_to_positive_candidates.end();++it)
if(rsIdentity->isARegularContact(*it))
setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ;
setOwnOpinion(*it, RsOpinion::POSITIVE);
}
}
const float RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM = 1.4f ;
const float RsReputations::REPUTATION_THRESHOLD_DEFAULT = 1.0f ;
static RsReputations::Opinion safe_convert_uint32t_to_opinion(uint32_t op)
static RsOpinion safe_convert_uint32t_to_opinion(uint32_t op)
{
return RsReputations::Opinion(std::min((uint32_t)op,UPPER_LIMIT)) ;
return RsOpinion(std::min( static_cast<uint32_t>(op), UPPER_LIMIT ));
}
/***** Implementation ******/
@ -631,13 +634,14 @@ bool p3GxsReputation::SendReputations(RsGxsReputationRequestItem *request)
return true;
}
void p3GxsReputation::locked_updateOpinion(const RsPeerId& from,const RsGxsId& about,RsReputations::Opinion op)
void p3GxsReputation::locked_updateOpinion(
const RsPeerId& from, const RsGxsId& about, RsOpinion op )
{
/* find matching Reputation */
std::map<RsGxsId, Reputation>::iterator rit = mReputations.find(about);
RsReputations::Opinion new_opinion = safe_convert_uint32t_to_opinion(op);
RsReputations::Opinion old_opinion = RsReputations::OPINION_NEUTRAL ; // default if not set
RsOpinion new_opinion = op;
RsOpinion old_opinion = RsOpinion::NEUTRAL ; // default if not set
bool updated = false ;
@ -658,9 +662,9 @@ void p3GxsReputation::locked_updateOpinion(const RsPeerId& from,const RsGxsId& a
std::cerr << " no preview record"<< std::endl;
#endif
if(new_opinion != RsReputations::OPINION_NEUTRAL)
if(new_opinion != RsOpinion::NEUTRAL)
{
mReputations[about] = Reputation(about);
mReputations[about] = Reputation();
rit = mReputations.find(about);
}
else
@ -674,11 +678,11 @@ void p3GxsReputation::locked_updateOpinion(const RsPeerId& from,const RsGxsId& a
Reputation& reputation = rit->second;
std::map<RsPeerId,RsReputations::Opinion>::iterator it2 = reputation.mOpinions.find(from) ;
std::map<RsPeerId,RsOpinion>::iterator it2 = reputation.mOpinions.find(from) ;
if(it2 == reputation.mOpinions.end())
{
if(new_opinion != RsReputations::OPINION_NEUTRAL)
if(new_opinion != RsOpinion::NEUTRAL)
{
reputation.mOpinions[from] = new_opinion; // filters potentially tweaked reputation score sent by friend
updated = true ;
@ -688,7 +692,7 @@ void p3GxsReputation::locked_updateOpinion(const RsPeerId& from,const RsGxsId& a
{
old_opinion = it2->second ;
if(new_opinion == RsReputations::OPINION_NEUTRAL)
if(new_opinion == RsOpinion::NEUTRAL)
{
reputation.mOpinions.erase(it2) ; // don't store when the opinion is neutral
updated = true ;
@ -700,7 +704,8 @@ void p3GxsReputation::locked_updateOpinion(const RsPeerId& from,const RsGxsId& a
}
}
if(reputation.mOpinions.empty() && reputation.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
if( reputation.mOpinions.empty() &&
reputation.mOwnOpinion == static_cast<int32_t>(RsOpinion::NEUTRAL) )
{
mReputations.erase(rit) ;
#ifdef DEBUG_REPUTATION
@ -766,9 +771,10 @@ bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,rstime_t latest_update)
* Opinion
****/
RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags)
RsReputationLevel p3GxsReputation::overallReputationLevel(
const RsGxsId& id, uint32_t* identity_flags )
{
ReputationInfo info ;
RsReputationInfo info ;
getReputationInfo(id,RsPgpId(),info) ;
RsPgpId owner_id ;
@ -805,12 +811,14 @@ bool p3GxsReputation::getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t&
return true ;
}
bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& ownerNode, RsReputations::ReputationInfo& info, bool stamp)
bool p3GxsReputation::getReputationInfo(
const RsGxsId& gxsid, const RsPgpId& ownerNode, RsReputationInfo& info,
bool stamp )
{
if(gxsid.isNull())
return false ;
rstime_t now = time(NULL) ;
rstime_t now = time(nullptr);
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
@ -822,8 +830,8 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
if(it == mReputations.end())
{
info.mOwnOpinion = RsReputations::OPINION_NEUTRAL ;
info.mFriendAverageScore = REPUTATION_THRESHOLD_DEFAULT ;
info.mOwnOpinion = RsOpinion::NEUTRAL ;
info.mFriendAverageScore = RS_REPUTATION_THRESHOLD_DEFAULT ;
info.mFriendsNegativeVotes = 0 ;
info.mFriendsPositiveVotes = 0 ;
@ -833,7 +841,9 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
{
Reputation& rep(it->second) ;
info.mOwnOpinion = RsReputations::Opinion(rep.mOwnOpinion) ;
info.mOwnOpinion =
safe_convert_uint32t_to_opinion(
static_cast<uint32_t>(rep.mOwnOpinion) );
info.mFriendAverageScore = rep.mFriendAverage ;
info.mFriendsNegativeVotes = rep.mFriendsNegative ;
info.mFriendsPositiveVotes = rep.mFriendsPositive ;
@ -853,18 +863,18 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
// 0 - check for own opinion. If positive or negative, it decides on the result
if(info.mOwnOpinion == RsReputations::OPINION_NEGATIVE)
if(info.mOwnOpinion == RsOpinion::NEGATIVE)
{
// own opinion is always read in priority
info.mOverallReputationLevel = RsReputations::REPUTATION_LOCALLY_NEGATIVE ;
info.mOverallReputationLevel = RsReputationLevel::LOCALLY_NEGATIVE;
return true ;
}
if(info.mOwnOpinion == RsReputations::OPINION_POSITIVE)
if(info.mOwnOpinion == RsOpinion::POSITIVE)
{
// own opinion is always read in priority
info.mOverallReputationLevel = RsReputations::REPUTATION_LOCALLY_POSITIVE ;
info.mOverallReputationLevel = RsReputationLevel::LOCALLY_POSITIVE;
return true ;
}
@ -889,7 +899,7 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
#ifdef DEBUG_REPUTATION2
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << owner_id << " is banned (found in banned nodes list)." << std::endl;
#endif
info.mOverallReputationLevel = RsReputations::REPUTATION_LOCALLY_NEGATIVE ;
info.mOverallReputationLevel = RsReputationLevel::LOCALLY_NEGATIVE;
return true ;
}
// also check the proxy
@ -899,17 +909,17 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
#ifdef DEBUG_REPUTATION2
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << owner_id << " is banned (found in proxy)." << std::endl;
#endif
info.mOverallReputationLevel = RsReputations::REPUTATION_LOCALLY_NEGATIVE ;
info.mOverallReputationLevel = RsReputationLevel::LOCALLY_NEGATIVE;
return true;
}
// 2 - now, our own opinion is neutral, which means we rely on what our friends tell
if(info.mFriendsPositiveVotes >= info.mFriendsNegativeVotes + mMinVotesForRemotelyPositive)
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_POSITIVE ;
info.mOverallReputationLevel = RsReputationLevel::REMOTELY_POSITIVE;
else if(info.mFriendsPositiveVotes + mMinVotesForRemotelyNegative <= info.mFriendsNegativeVotes)
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_NEGATIVE ;
info.mOverallReputationLevel = RsReputationLevel::REMOTELY_NEGATIVE;
else
info.mOverallReputationLevel = RsReputations::REPUTATION_NEUTRAL ;
info.mOverallReputationLevel = RsReputationLevel::NEUTRAL;
#ifdef DEBUG_REPUTATION2
std::cerr << " information present. OwnOp = " << info.mOwnOpinion << ", owner node=" << owner_id << ", overall score=" << info.mAssessment << std::endl;
@ -969,16 +979,20 @@ void p3GxsReputation::banNode(const RsPgpId& id,bool b)
}
}
}
RsReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id)
{ return overallReputationLevel(id, nullptr); }
bool p3GxsReputation::isNodeBanned(const RsPgpId& id)
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
return mBannedPgpIds.find(id) != mBannedPgpIds.end();
}
bool p3GxsReputation::isIdentityBanned(const RsGxsId &id)
{
RsReputations::ReputationInfo info ;
RsReputationInfo info;
if(!getReputationInfo(id,RsPgpId(),info))
return false ;
@ -986,10 +1000,11 @@ bool p3GxsReputation::isIdentityBanned(const RsGxsId &id)
#ifdef DEBUG_REPUTATION
std::cerr << "isIdentityBanned(): returning " << (info.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE) << " for GXS id " << id << std::endl;
#endif
return info.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE ;
return info.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE;
}
bool p3GxsReputation::getOwnOpinion(const RsGxsId& gxsid, RsReputations::Opinion& opinion)
bool p3GxsReputation::getOwnOpinion(
const RsGxsId& gxsid, RsOpinion& opinion )
{
#ifdef DEBUG_REPUTATION
std::cerr << "setOwnOpinion(): for GXS id " << gxsid << " to " << opinion << std::endl;
@ -1000,19 +1015,21 @@ bool p3GxsReputation::getOwnOpinion(const RsGxsId& gxsid, RsReputations::Opinion
return false ;
}
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
RS_STACK_MUTEX(mReputationMtx);
std::map<RsGxsId, Reputation>::iterator rit = mReputations.find(gxsid);
if(rit != mReputations.end())
opinion = RsReputations::Opinion(rit->second.mOwnOpinion) ;
else
opinion = RsReputations::OPINION_NEUTRAL ;
if(rit != mReputations.end())
opinion = safe_convert_uint32t_to_opinion(
static_cast<uint32_t>(rit->second.mOwnOpinion) );
else
opinion = RsOpinion::NEUTRAL;
return true;
}
bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::Opinion& opinion)
bool p3GxsReputation::setOwnOpinion(
const RsGxsId& gxsid, RsOpinion opinion )
{
#ifdef DEBUG_REPUTATION
std::cerr << "setOwnOpinion(): for GXS id " << gxsid << " to " << opinion << std::endl;
@ -1022,8 +1039,8 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
std::cerr << " ID " << gxsid << " is rejected. Look for a bug in calling method." << std::endl;
return false ;
}
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
RS_STACK_MUTEX(mReputationMtx);
std::map<RsGxsId, Reputation>::iterator rit;
@ -1033,7 +1050,7 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
if (rit == mReputations.end())
{
#warning csoler 2017-01-05: We should set the owner node id here.
mReputations[gxsid] = Reputation(gxsid);
mReputations[gxsid] = Reputation();
rit = mReputations.find(gxsid);
}
@ -1041,7 +1058,7 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
Reputation &reputation = rit->second;
if (reputation.mOwnOpinionTs != 0)
{
if (reputation.mOwnOpinion == opinion)
if (reputation.mOwnOpinion == static_cast<int32_t>(opinion))
{
// if opinion is accurate, don't update.
return false;
@ -1060,8 +1077,8 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
}
}
rstime_t now = time(NULL);
reputation.mOwnOpinion = opinion;
rstime_t now = time(nullptr);
reputation.mOwnOpinion = static_cast<int32_t>(opinion);
reputation.mOwnOpinionTs = now;
reputation.updateReputation();
@ -1126,7 +1143,7 @@ bool p3GxsReputation::saveList(bool& cleanup, std::list<RsItem*> &savelist)
item->mOwnerNodeId = rit->second.mOwnerNode;
item->mLastUsedTS = rit->second.mLastUsedTS;
std::map<RsPeerId, RsReputations::Opinion>::iterator oit;
std::map<RsPeerId, RsOpinion>::iterator oit;
for(oit = rit->second.mOpinions.begin(); oit != rit->second.mOpinions.end(); ++oit)
{
// should be already limited.
@ -1492,15 +1509,16 @@ void Reputation::updateReputation()
// accounts for all friends. Neutral opinions count for 1-1=0
// because the average is performed over only accessible peers (not the total number) we need to shift to 1
for(std::map<RsPeerId,RsReputations::Opinion>::const_iterator it(mOpinions.begin());it!=mOpinions.end();++it)
for( std::map<RsPeerId,RsOpinion>::const_iterator it(mOpinions.begin());
it != mOpinions.end(); ++it )
{
if( it->second == RsReputations::OPINION_NEGATIVE)
if( it->second == RsOpinion::NEGATIVE)
++mFriendsNegative ;
if( it->second == RsReputations::OPINION_POSITIVE)
if( it->second == RsOpinion::POSITIVE)
++mFriendsPositive ;
friend_total += it->second - 1 ;
friend_total += static_cast<int>(it->second) - 1;
}
if(mOpinions.empty()) // includes the case of no friends!
@ -1554,11 +1572,10 @@ void Reputation::updateReputation()
}
// now compute a bias for PGP-signed ids.
if(mOwnOpinion == RsReputations::OPINION_NEUTRAL)
mReputationScore = mFriendAverage ;
else
mReputationScore = (float)mOwnOpinion ;
if(mOwnOpinion == static_cast<int32_t>(RsOpinion::NEUTRAL))
mReputationScore = mFriendAverage;
else mReputationScore = static_cast<float>(mOwnOpinion);
}
void p3GxsReputation::debug_print()
@ -1567,19 +1584,22 @@ void p3GxsReputation::debug_print()
std::cerr << " GXS ID data: " << std::endl;
std::cerr << std::dec ;
std::map<RsGxsId,Reputation> rep_copy;
std::map<RsGxsId,Reputation> rep_copy;
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
rep_copy = mReputations ;
}
rstime_t now = time(NULL) ;
{
RS_STACK_MUTEX(mReputationMtx);
rep_copy = mReputations;
}
for(std::map<RsGxsId,Reputation>::const_iterator it(rep_copy.begin());it!=rep_copy.end();++it)
rstime_t now = time(nullptr);
for( std::map<RsGxsId,Reputation>::const_iterator it(rep_copy.begin());
it != rep_copy.end(); ++it )
{
RsReputations::ReputationInfo info ;
getReputationInfo(it->first,RsPgpId(),info,false) ;
uint32_t lev = info.mOverallReputationLevel;
RsReputationInfo info;
getReputationInfo(it->first, RsPgpId(), info, false);
uint32_t lev = static_cast<uint32_t>(info.mOverallReputationLevel);
std::cerr << " " << it->first << ": own: " << it->second.mOwnOpinion
<< ", PGP id=" << it->second.mOwnerNode
@ -1596,7 +1616,7 @@ std::map<RsGxsId,Reputation> rep_copy;
#endif
}
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
RS_STACK_MUTEX(mReputationMtx);
std::cerr << " Banned RS nodes by ID: " << std::endl;
for(std::map<RsPgpId,BannedNodeInfo>::const_iterator it(mBannedPgpIds.begin());it!=mBannedPgpIds.end();++it)

View file

@ -64,15 +64,17 @@ struct BannedNodeInfo
class Reputation
{
public:
Reputation()
:mOwnOpinion(RsReputations::OPINION_NEUTRAL), mOwnOpinionTs(0),mFriendAverage(1.0f), mReputationScore(RsReputations::OPINION_NEUTRAL),mIdentityFlags(0){ }
Reputation(const RsGxsId& /*about*/)
:mOwnOpinion(RsReputations::OPINION_NEUTRAL), mOwnOpinionTs(0),mFriendAverage(1.0f), mReputationScore(RsReputations::OPINION_NEUTRAL),mIdentityFlags(0){ }
Reputation() :
mOwnOpinion(static_cast<int32_t>(RsOpinion::NEUTRAL)), mOwnOpinionTs(0),
mFriendAverage(1.0f),
/* G10h4ck: TODO shouln't this be initialized with
* RsReputation::NEUTRAL or UNKOWN? */
mReputationScore(static_cast<float>(RsOpinion::NEUTRAL)),
mIdentityFlags(0) {}
void updateReputation();
std::map<RsPeerId, RsReputations::Opinion> mOpinions;
std::map<RsPeerId, RsOpinion> mOpinions;
int32_t mOwnOpinion;
rstime_t mOwnOpinionTs;
@ -91,11 +93,6 @@ public:
//!The p3GxsReputation service.
/**
*
*
*/
class p3GxsReputation: public p3Service, public p3Config, public RsGixsReputation, public RsReputations /* , public pqiMonitor */
{
public:
@ -103,20 +100,26 @@ public:
virtual RsServiceInfo getServiceInfo();
/***** Interface for RsReputations *****/
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) ;
virtual bool getOwnOpinion(const RsGxsId& key_id, Opinion& op) ;
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) ;
virtual bool setOwnOpinion(const RsGxsId& key_id, RsOpinion op);
virtual bool getOwnOpinion(const RsGxsId& key_id, RsOpinion& op) ;
virtual bool getReputationInfo(
const RsGxsId& id, const RsPgpId& ownerNode, RsReputationInfo& info,
bool stamp = true );
virtual bool isIdentityBanned(const RsGxsId& id) ;
virtual bool isNodeBanned(const RsPgpId& id);
virtual void banNode(const RsPgpId& id,bool b) ;
virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL);
virtual void setNodeAutoPositiveOpinionForContacts(bool b) ;
virtual bool nodeAutoPositiveOpinionForContacts() ;
RsReputationLevel overallReputationLevel(const RsGxsId& id) override;
virtual void setRememberDeletedNodesThreshold(uint32_t days) ;
virtual uint32_t rememberDeletedNodesThreshold() ;
virtual RsReputationLevel overallReputationLevel(
const RsGxsId& id, uint32_t* identity_flags );
virtual void setAutoPositiveOpinionForContacts(bool b) ;
virtual bool autoPositiveOpinionForContacts() ;
virtual void setRememberBannedIdThreshold(uint32_t days) ;
virtual uint32_t rememberBannedIdThreshold() ;
uint32_t thresholdForRemotelyNegativeReputation();
uint32_t thresholdForRemotelyPositiveReputation();
@ -149,7 +152,8 @@ private:
void updateBannedNodesProxy();
// internal update of data. Takes care of cleaning empty boxes.
void locked_updateOpinion(const RsPeerId &from, const RsGxsId &about, RsReputations::Opinion op);
void locked_updateOpinion(
const RsPeerId& from, const RsGxsId& about, RsOpinion op);
bool loadReputationSet(RsGxsReputationSetItem *item, const std::set<RsPeerId> &peerSet);
#ifdef TO_REMOVE
bool loadReputationSet_deprecated3(RsGxsReputationSetItem_deprecated3 *item, const std::set<RsPeerId> &peerSet);

View file

@ -21,6 +21,7 @@
* *
*******************************************************************************/
#include <unistd.h>
#include <algorithm>
#include "services/p3idservice.h"
#include "pgp/pgpauxutils.h"
@ -207,6 +208,32 @@ void p3IdService::setNes(RsNetworkExchangeService *nes)
mNes = nes;
}
bool p3IdService::getIdentitiesInfo(
const std::set<RsGxsId>& ids, std::vector<RsGxsIdGroup>& idsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> idsList;
for (auto&& id : ids) idsList.push_back(RsGxsGroupId(id));
if( !requestGroupInfo(token, opts, idsList)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, idsInfo);
}
bool p3IdService::getIdentitiesSummaries(std::list<RsGroupMetaData>& ids)
{
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, ids);
}
uint32_t p3IdService::idAuthenPolicy()
{
uint32_t policy = 0;
@ -687,11 +714,12 @@ bool p3IdService::getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
// This step is needed, because p3GxsReputation does not know all identities, and might not have any data for
// the ones in the contact list. So we change them on demand.
if(is_a_contact && rsReputations->nodeAutoPositiveOpinionForContacts())
if(is_a_contact && rsReputations->autoPositiveOpinionForContacts())
{
RsReputations::Opinion op ;
if(rsReputations->getOwnOpinion(id,op) && op == RsReputations::OPINION_NEUTRAL)
rsReputations->setOwnOpinion(id,RsReputations::OPINION_POSITIVE) ;
RsOpinion op;
if( rsReputations->getOwnOpinion(id,op) &&
op == RsOpinion::NEUTRAL )
rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE);
}
std::map<RsGxsId,keyTSInfo>::const_iterator it = mKeysTS.find(id) ;
@ -727,6 +755,46 @@ bool p3IdService::isOwnId(const RsGxsId& id)
return std::find(mOwnIds.begin(),mOwnIds.end(),id) != mOwnIds.end() ;
}
bool p3IdService::getOwnSignedIds(std::vector<RsGxsId> ids)
{
ids.clear();
std::chrono::seconds maxWait(5);
auto timeout = std::chrono::steady_clock::now() + maxWait;
while( !ownIdsAreLoaded() && std::chrono::steady_clock::now() < timeout )
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(ownIdsAreLoaded())
{
RS_STACK_MUTEX(mIdMtx);
ids.reserve(mOwnSignedIds.size());
ids.insert(ids.end(), mOwnSignedIds.begin(), mOwnSignedIds.end());
return true;
}
return false;
}
bool p3IdService::getOwnPseudonimousIds(std::vector<RsGxsId> ids)
{
ids.clear();
std::vector<RsGxsId> signedV;
// this implicitely ensure ids are already loaded ;)
if(!getOwnSignedIds(signedV)) return false;
std::set<RsGxsId> signedS(signedV.begin(), signedV.end());
{
RS_STACK_MUTEX(mIdMtx);
std::copy_if(mOwnIds.begin(), mOwnIds.end(), ids.end(),
[&](const RsGxsId& id) {return !signedS.count(id);});
}
return true;
}
bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only)
{
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
@ -742,6 +810,11 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only)
return true ;
}
bool p3IdService::identityToBase64( const RsGxsId& id,
std::string& base64String )
{ return serialiseIdentityToMemory(id, base64String); }
bool p3IdService::serialiseIdentityToMemory( const RsGxsId& id,
std::string& radix_string )
{
@ -803,6 +876,10 @@ void p3IdService::handle_get_serialized_grp(uint32_t token)
mSerialisedIdentities[RsGxsId(id)] = s ;
}
bool p3IdService::identityFromBase64(
const std::string& base64String, RsGxsId& id )
{ return deserialiseIdentityFromMemory(base64String, &id); }
bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
RsGxsId* id /* = nullptr */)
{
@ -826,6 +903,47 @@ bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
return true;
}
bool p3IdService::createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar,
bool pseudonimous, const std::string& pgpPassword)
{
if(!pgpPassword.empty())
std::cerr<< __PRETTY_FUNCTION__ << " Warning! PGP Password handling "
<< "not implemented yet!" << std::endl;
RsIdentityParameters params;
params.isPgpLinked = !pseudonimous;
params.nickname = name;
params.mImage = avatar;
uint32_t token;
if(!createIdentity(token, params))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed creating group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed."
<< std::endl;
return false;
}
RsGroupMetaData meta;
if(!RsGenExchange::getPublishedGroupMeta(token, meta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
id = RsGxsId(meta.mGroupId);
return true;
}
bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
{
@ -863,6 +981,26 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
return true;
}
bool p3IdService::updateIdentity(RsGxsIdGroup& identityData)
{
uint32_t token;
if(!updateGroup(token, identityData))
{
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;
}
return true;
}
bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
{
#ifdef DEBUG_IDS
@ -876,6 +1014,27 @@ bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
return false;
}
bool p3IdService::deleteIdentity(RsGxsId& id)
{
uint32_t token;
RsGxsGroupId grouId = RsGxsGroupId(id);
if(!deleteGroup(token, grouId))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed deleting group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
return true;
}
bool p3IdService::deleteIdentity(uint32_t& token, RsGxsIdGroup &group)
{
#ifdef DEBUG_IDS
@ -883,7 +1042,7 @@ bool p3IdService::deleteIdentity(uint32_t& token, RsGxsIdGroup &group)
std::cerr << std::endl;
#endif
deleteGroup(token, group);
deleteGroup(token, group.mMeta.mGroupId);
return false;
}
@ -1012,10 +1171,10 @@ bool p3IdService::requestKey(const RsGxsId &id, const std::list<RsPeerId>& peers
std::cerr << "p3IdService::requesting key " << id <<std::endl;
#endif
RsReputations::ReputationInfo info ;
RsReputationInfo info;
rsReputations->getReputationInfo(id,RsPgpId(),info) ;
if(info.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
if( info.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE )
{
std::cerr << "(II) not requesting Key " << id << " because it has been banned." << std::endl;
@ -1796,16 +1955,16 @@ bool p3IdService::updateGroup(uint32_t& token, RsGxsIdGroup &group)
return true;
}
bool p3IdService::deleteGroup(uint32_t& token, RsGxsIdGroup &group)
bool p3IdService::deleteGroup(uint32_t& token, RsGxsGroupId& groupId)
{
RsGxsId id(group.mMeta.mGroupId);
RsGxsId id(groupId);
#ifdef DEBUG_IDS
std::cerr << "p3IdService::deleteGroup() Deleting RsGxsId: " << id;
std::cerr << std::endl;
#endif
RsGenExchange::deleteGroup(token,group.mMeta.mGroupId);
RsGenExchange::deleteGroup(token, groupId);
// if its in the cache - clear it.
{

View file

@ -215,9 +215,8 @@ struct SerialisedIdentityStruct
rstime_t mLastUsageTS;
};
// Not sure exactly what should be inherited here?
// Chris - please correct as necessary.
// We cache all identities, and provide alternative (instantaneous)
// functions to extract info, rather than the horrible Token system.
class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config
{
public:
@ -239,6 +238,13 @@ public:
/* Data Specific Interface */
/// @see RsIdentity
bool getIdentitiesInfo(const std::set<RsGxsId>& ids,
std::vector<RsGxsIdGroup>& idsInfo ) override;
/// @see RsIdentity
bool getIdentitiesSummaries(std::list<RsGroupMetaData>& ids) override;
// These are exposed via RsIdentity.
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups);
@ -248,7 +254,7 @@ public:
// These are local - and not exposed via RsIdentity.
virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group);
virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group);
virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group);
virtual bool deleteGroup(uint32_t& token, RsGxsGroupId& group);
//virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
/**************** RsIdentity External Interface.
@ -263,12 +269,28 @@ public:
//virtual bool getNickname(const RsGxsId &id, std::string &nickname);
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
//
RS_DEPRECATED_FOR(RsReputations)
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
bool absOpinion, int score);
/// @see RsIdentity
virtual bool createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar = RsGxsImage(),
bool pseudonimous = true, const std::string& pgpPassword = "" ) override;
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params);
/// @see RsIdentity
bool updateIdentity(RsGxsIdGroup& identityData) override;
RS_DEPRECATED
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group);
/// @see RsIdentity
bool deleteIdentity(RsGxsId& id) override;
RS_DEPRECATED
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group);
virtual void setDeleteBannedNodesThreshold(uint32_t days) ;
@ -289,6 +311,12 @@ public:
/**************** RsGixs Implementation ***************/
/// @see RsIdentity
bool getOwnSignedIds(std::vector<RsGxsId> ids) override;
/// @see RsIdentity
bool getOwnPseudonimousIds(std::vector<RsGxsId> ids) override;
virtual bool getOwnIds(std::list<RsGxsId> &ownIds, bool signed_only = false);
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
@ -350,6 +378,15 @@ public:
const RsIdentityUsage &use_info );
virtual bool requestPrivateKey(const RsGxsId &id);
/// @see RsIdentity
bool identityToBase64( const RsGxsId& id,
std::string& base64String ) override;
/// @see RsIdentity
bool identityFromBase64( const std::string& base64String,
RsGxsId& id ) override;
virtual bool serialiseIdentityToMemory(const RsGxsId& id,
std::string& radix_string);
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string,
@ -599,7 +636,9 @@ private:
rstime_t mLastKeyCleaningTime ;
rstime_t mLastConfigUpdate ;
bool mOwnIdsLoaded ;
bool mOwnIdsLoaded;
bool ownIdsAreLoaded() { RS_STACK_MUTEX(mIdMtx); return mOwnIdsLoaded; }
bool mAutoAddFriendsIdentitiesAsContacts;
uint32_t mMaxKeepKeysBanned ;
};

View file

@ -187,8 +187,7 @@ void p3PhotoService::groupsChanged(std::list<RsGxsGroupId>& grpIds)
}
void p3PhotoService::msgsChanged(
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >& msgs)
void p3PhotoService::msgsChanged(GxsMsgIdResult& msgs)
{
RsStackMutex stack(mPhotoMutex);

View file

@ -56,8 +56,7 @@ public:
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
void msgsChanged(std::map<RsGxsGroupId,
std::vector<RsGxsMessageId> >& msgs);
void msgsChanged(GxsMsgIdResult& msgs);
RsTokenService* getTokenService();

View file

@ -123,6 +123,7 @@ bool p3Posted::getPostData(const uint32_t &token, std::vector<RsPostedPost> &msg
{
RsPostedPost msg = postItem->mPost;
msg.mMeta = postItem->meta;
postItem->toPostedPost(msg, true);
msg.calculateScores(now);
msgs.push_back(msg);
@ -291,8 +292,10 @@ bool p3Posted::createPost(uint32_t &token, RsPostedPost &msg)
std::cerr << std::endl;
RsGxsPostedPostItem* msgItem = new RsGxsPostedPostItem();
msgItem->mPost = msg;
msgItem->meta = msg.mMeta;
//msgItem->mPost = msg;
//msgItem->meta = msg.mMeta;
msgItem->fromPostedPost(msg, true);
RsGenExchange::publishMsg(token, msgItem);
return true;

View file

@ -89,12 +89,12 @@ virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgI
std::vector<RsGxsComment> &msgs )
{ return mCommentService->getGxsRelatedComments(token, msgs); }
virtual bool createComment(uint32_t &token, RsGxsComment &msg)
virtual bool createNewComment(uint32_t &token, RsGxsComment &msg)
{
return mCommentService->createGxsComment(token, msg);
}
virtual bool createVote(uint32_t &token, RsGxsVote &msg)
virtual bool createNewVote(uint32_t &token, RsGxsVote &msg)
{
return mCommentService->createGxsVote(token, msg);
}

View file

@ -49,8 +49,8 @@ std::string generateRandomServiceId();
//TODO : encryption and upload / download rate implementation
// p3FastService(uint16_t type)
// :pqiService((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) type) << 8)),
// p3FastService(uint16_t type)
// :pqiService((RsServiceInfo::RsServiceInfoUIn16ToFullServiceId(type)),
class p3FastService: public pqiService