mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-05 21:04:14 -04:00
made RsReputation::overallReputationLevel() to also return the identity ownership flags so that we dont need to rely on async calls to p3IdService to get them
This commit is contained in:
parent
013eb93f70
commit
6a9b697e42
6 changed files with 46 additions and 15 deletions
|
@ -177,7 +177,7 @@ class RsGixsReputation
|
|||
{
|
||||
public:
|
||||
// get Reputation.
|
||||
virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id) = 0;
|
||||
virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL) = 0;
|
||||
};
|
||||
|
||||
/*** This Class pulls all the GXS Interfaces together ****/
|
||||
|
|
|
@ -63,7 +63,10 @@ public:
|
|||
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0;
|
||||
virtual bool getOwnOpinion(const RsGxsId& key_id, Opinion& op) =0;
|
||||
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) =0;
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id)=0;
|
||||
|
||||
// This returns the reputation level and also the flags of the identity service for that id. This is useful in order to get these flags without relying on the async method of p3Identity
|
||||
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL)=0;
|
||||
|
||||
// parameters
|
||||
|
||||
|
|
|
@ -768,14 +768,45 @@ bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,time_t latest_update)
|
|||
* Opinion
|
||||
****/
|
||||
|
||||
RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id)
|
||||
RsReputations::ReputationLevel p3GxsReputation::overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags)
|
||||
{
|
||||
ReputationInfo info ;
|
||||
getReputationInfo(id,RsPgpId(),info) ;
|
||||
|
||||
RsPgpId owner_id ;
|
||||
|
||||
if(identity_flags)
|
||||
getIdentityFlagsAndOwnerId(id,*identity_flags,owner_id);
|
||||
|
||||
return info.mOverallReputationLevel ;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags,RsPgpId& owner_id)
|
||||
{
|
||||
if(gxsid.isNull())
|
||||
return false ;
|
||||
|
||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
std::map<RsGxsId,Reputation>::iterator it = mReputations.find(gxsid) ;
|
||||
|
||||
if(it == mReputations.end())
|
||||
return false ;
|
||||
|
||||
if(!(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_UP_TO_DATE))
|
||||
return false ;
|
||||
|
||||
if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_LINKED)
|
||||
identity_flags |= RS_IDENTITY_FLAGS_PGP_LINKED ;
|
||||
|
||||
if(it->second.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_KNOWN)
|
||||
identity_flags |= RS_IDENTITY_FLAGS_PGP_KNOWN ;
|
||||
|
||||
owner_id = it->second.mOwnerNode ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& ownerNode, RsReputations::ReputationInfo& info, bool stamp)
|
||||
{
|
||||
if(gxsid.isNull())
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
|
||||
virtual bool isNodeBanned(const RsPgpId& id);
|
||||
virtual void banNode(const RsPgpId& id,bool b) ;
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id);
|
||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id,uint32_t *identity_flags=NULL);
|
||||
|
||||
virtual void setNodeAutoPositiveOpinionForContacts(bool b) ;
|
||||
virtual bool nodeAutoPositiveOpinionForContacts() ;
|
||||
|
@ -143,6 +143,7 @@ public:
|
|||
virtual bool loadList(std::list<RsItem*>& load) ;
|
||||
|
||||
private:
|
||||
bool getIdentityFlagsAndOwnerId(const RsGxsId& gxsid, uint32_t& identity_flags, RsPgpId &owner_id);
|
||||
|
||||
bool processIncoming();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue