mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
moved isIdentitybanned from p3GxsReputations to p3IdService, so as to avoid calling back p3IdService from p3GxsReputations, which simplifies the code
This commit is contained in:
parent
720c6fd915
commit
e611b2bb05
15 changed files with 100 additions and 63 deletions
|
@ -34,7 +34,6 @@
|
||||||
#include "pqi/p3historymgr.h"
|
#include "pqi/p3historymgr.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "retroshare/rsiface.h"
|
#include "retroshare/rsiface.h"
|
||||||
#include "retroshare/rsreputations.h"
|
|
||||||
#include "retroshare/rsidentity.h"
|
#include "retroshare/rsidentity.h"
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
#include "gxs/rsgixs.h"
|
#include "gxs/rsgixs.h"
|
||||||
|
@ -139,7 +138,7 @@ bool DistributedChatService::handleRecvChatLobbyMsgItem(RsChatMsgItem *ci)
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rsReputations->isIdentityBanned(cli->signature.keyId))
|
if(rsIdentity->isBanned(cli->signature.keyId))
|
||||||
{
|
{
|
||||||
std::cerr << "(WW) Received lobby msg/item from banned identity " << cli->signature.keyId << ". Dropping it." << std::endl;
|
std::cerr << "(WW) Received lobby msg/item from banned identity " << cli->signature.keyId << ". Dropping it." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -648,7 +647,7 @@ void DistributedChatService::handleRecvChatLobbyEventItem(RsChatLobbyEventItem *
|
||||||
#endif
|
#endif
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
|
|
||||||
if(rsReputations->isIdentityBanned(item->signature.keyId))
|
if(rsIdentity->isBanned(item->signature.keyId))
|
||||||
{
|
{
|
||||||
std::cerr << "(WW) Received lobby msg/item from banned identity " << item->signature.keyId << ". Dropping it." << std::endl;
|
std::cerr << "(WW) Received lobby msg/item from banned identity " << item->signature.keyId << ". Dropping it." << std::endl;
|
||||||
return ;
|
return ;
|
||||||
|
|
|
@ -191,7 +191,6 @@
|
||||||
#include "turtle/p3turtle.h"
|
#include "turtle/p3turtle.h"
|
||||||
#include "gxs/rsgixs.h"
|
#include "gxs/rsgixs.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "retroshare/rsreputations.h"
|
|
||||||
|
|
||||||
#include "p3grouter.h"
|
#include "p3grouter.h"
|
||||||
#include "grouteritems.h"
|
#include "grouteritems.h"
|
||||||
|
@ -1994,7 +1993,7 @@ bool p3GRouter::verifySignedDataItem(RsGRouterAbstractMsgItem *item,uint32_t& er
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(rsReputations->isIdentityBanned(item->signature.keyId))
|
if(rsIdentity->isBanned(item->signature.keyId))
|
||||||
{
|
{
|
||||||
std::cerr << "(WW) received global router message from banned identity " << item->signature.keyId << ". Rejecting the message." << std::endl;
|
std::cerr << "(WW) received global router message from banned identity " << item->signature.keyId << ". Rejecting the message." << std::endl;
|
||||||
return false ;
|
return false ;
|
||||||
|
|
|
@ -204,7 +204,6 @@
|
||||||
#include "rsgxsnetservice.h"
|
#include "rsgxsnetservice.h"
|
||||||
#include "gxssecurity.h"
|
#include "gxssecurity.h"
|
||||||
#include "retroshare/rsconfig.h"
|
#include "retroshare/rsconfig.h"
|
||||||
#include "retroshare/rsreputations.h"
|
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
#include "retroshare/rsgxscircles.h"
|
#include "retroshare/rsgxscircles.h"
|
||||||
#include "pgp/pgpauxutils.h"
|
#include "pgp/pgpauxutils.h"
|
||||||
|
@ -2928,9 +2927,8 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||||
#endif
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// FIXTESTS global variable rsReputations not available in unittests!
|
|
||||||
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all messages!" << std::endl; }
|
if(rsIdentity && rsIdentity->isBanned(syncItem->authorId))
|
||||||
if(rsReputations && rsReputations->isIdentityBanned(syncItem->authorId))
|
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_1
|
#ifdef NXS_NET_DEBUG_1
|
||||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
|
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
|
||||||
|
@ -3174,8 +3172,8 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
||||||
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||||
}
|
}
|
||||||
// FIXTESTS global variable rsReputations not available in unittests!
|
// FIXTESTS global variable rsReputations not available in unittests!
|
||||||
if(rsReputations == 0){ std::cerr << "rsReputations==0, accepting all groups!" << std::endl; }
|
|
||||||
if(!grpSyncItem->authorId.isNull() && rsReputations && rsReputations->isIdentityBanned(grpSyncItem->authorId))
|
if(!grpSyncItem->authorId.isNull() && rsIdentity && rsIdentity->isBanned(grpSyncItem->authorId))
|
||||||
{
|
{
|
||||||
#ifdef NXS_NET_DEBUG_0
|
#ifdef NXS_NET_DEBUG_0
|
||||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
|
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "rsgxsutil.h"
|
#include "rsgxsutil.h"
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
#include "retroshare/rspeers.h"
|
#include "retroshare/rspeers.h"
|
||||||
#include "retroshare/rsreputations.h"
|
|
||||||
#include "pqi/pqihash.h"
|
#include "pqi/pqihash.h"
|
||||||
#include "gxs/rsgixs.h"
|
#include "gxs/rsgixs.h"
|
||||||
|
|
||||||
|
@ -165,7 +164,7 @@ bool RsGxsIntegrityCheck::check()
|
||||||
std::cerr << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
|
std::cerr << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(grp->metaData->mAuthorId))
|
if(rsIdentity!=NULL && !rsIdentity->isBanned(grp->metaData->mAuthorId))
|
||||||
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
|
used_gxs_ids.insert(grp->metaData->mAuthorId) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +246,7 @@ bool RsGxsIntegrityCheck::check()
|
||||||
#ifdef GXSUTIL_DEBUG
|
#ifdef GXSUTIL_DEBUG
|
||||||
std::cerr << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
std::cerr << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
if(rsReputations!=NULL && !rsReputations->isIdentityBanned(msg->metaData->mAuthorId))
|
if(rsIdentity!=NULL && !rsIdentity->isBanned(msg->metaData->mAuthorId))
|
||||||
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
|
used_gxs_ids.insert(msg->metaData->mAuthorId) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,7 @@ virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||||
|
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
virtual bool isARegularContact(const RsGxsId& id) = 0 ;
|
||||||
|
virtual bool isBanned(const RsGxsId& id) =0;
|
||||||
|
|
||||||
// Specific RsIdentity Functions....
|
// Specific RsIdentity Functions....
|
||||||
/* Specific Service Data */
|
/* Specific Service Data */
|
||||||
|
|
|
@ -50,14 +50,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0;
|
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0;
|
||||||
virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) =0 ;
|
virtual bool getReputationInfo(const RsGxsId& id,const RsPgpId& owner_id,ReputationInfo& info) =0 ;
|
||||||
virtual void setNodeAutoBanThreshold(uint32_t n) =0;
|
virtual void setNodeAutoBanThreshold(uint32_t n) =0;
|
||||||
virtual uint32_t nodeAutoBanThreshold() =0;
|
virtual uint32_t nodeAutoBanThreshold() =0;
|
||||||
|
|
||||||
// This one is a proxy designed to allow fast checking of a GXS id.
|
// This one is a proxy designed to allow fast checking of a GXS id.
|
||||||
// it basically returns true if assessment is not ASSESSMENT_OK
|
// it basically returns true if assessment is not ASSESSMENT_OK
|
||||||
|
|
||||||
virtual bool isIdentityBanned(const RsGxsId& id) =0;
|
virtual bool isIdentityBanned(const RsGxsId& id,const RsPgpId& owner_node) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// To access reputations from anywhere
|
// To access reputations from anywhere
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
/****
|
/****
|
||||||
* #define DEBUG_REPUTATION 1
|
* #define DEBUG_REPUTATION 1
|
||||||
****/
|
****/
|
||||||
|
#define DEBUG_REPUTATION 1
|
||||||
|
|
||||||
/************ IMPLEMENTATION NOTES *********************************
|
/************ IMPLEMENTATION NOTES *********************************
|
||||||
*
|
*
|
||||||
|
@ -335,9 +336,33 @@ void p3GxsReputation::cleanup()
|
||||||
// remove opinions from friends that havn't been seen online for more than the specified delay
|
// remove opinions from friends that havn't been seen online for more than the specified delay
|
||||||
|
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << "p3GxsReputation::cleanup() " << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented. TODO!" << std::endl;
|
std::cerr << "p3GxsReputation::cleanup() " << std::endl;
|
||||||
|
|
||||||
|
// remove optionions about identities that do not exist anymore. That will in particular avoid asking p3idservice about deleted
|
||||||
|
// identities, which would cause an excess of hits to the database.
|
||||||
|
|
||||||
|
bool updated = false ;
|
||||||
|
|
||||||
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
|
||||||
|
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();)
|
||||||
|
if(it->second.mOpinions.empty() && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
||||||
|
{
|
||||||
|
std::map<RsGxsId,Reputation>::iterator tmp(it) ;
|
||||||
|
++tmp ;
|
||||||
|
mReputations.erase(it) ;
|
||||||
|
it = tmp ;
|
||||||
|
#ifdef DEBUG_REPUTATION
|
||||||
|
std::cerr << " ID " << it->first << ": own is neutral and no opinions from friends => remove entry" << std::endl;
|
||||||
|
#endif
|
||||||
|
updated = true ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++it ;
|
||||||
|
|
||||||
|
if(updated)
|
||||||
|
IndicateConfigChanged() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3GxsReputation::updateActiveFriends()
|
void p3GxsReputation::updateActiveFriends()
|
||||||
|
@ -668,7 +693,7 @@ bool p3GxsReputation::updateLatestUpdate(RsPeerId peerid,time_t latest_update)
|
||||||
* Opinion
|
* Opinion
|
||||||
****/
|
****/
|
||||||
|
|
||||||
bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, RsReputations::ReputationInfo& info)
|
bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& owner_id, RsReputations::ReputationInfo& info)
|
||||||
{
|
{
|
||||||
if(gxsid.isNull())
|
if(gxsid.isNull())
|
||||||
return false ;
|
return false ;
|
||||||
|
@ -678,25 +703,34 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, RsReputations::Rep
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << "getReputationInfo() for " << gxsid << std::endl;
|
std::cerr << "getReputationInfo() for " << gxsid << std::endl;
|
||||||
#endif
|
#endif
|
||||||
Reputation& rep(mReputations[gxsid]) ;
|
std::map<RsGxsId,Reputation>::const_iterator it = mReputations.find(gxsid) ;
|
||||||
|
|
||||||
|
if(it == mReputations.end())
|
||||||
|
{
|
||||||
|
info.mOwnOpinion = RsReputations::OPINION_NEUTRAL ;
|
||||||
|
info.mOverallReputationScore = RsReputations::REPUTATION_THRESHOLD_DEFAULT ;
|
||||||
|
info.mFriendAverage = REPUTATION_THRESHOLD_DEFAULT ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const Reputation& rep(it->second) ;
|
||||||
|
|
||||||
info.mOwnOpinion = RsReputations::Opinion(rep.mOwnOpinion) ;
|
info.mOwnOpinion = RsReputations::Opinion(rep.mOwnOpinion) ;
|
||||||
info.mOverallReputationScore = rep.mReputation ;
|
info.mOverallReputationScore = rep.mReputation ;
|
||||||
info.mFriendAverage = rep.mFriendAverage ;
|
info.mFriendAverage = rep.mFriendAverage ;
|
||||||
|
|
||||||
if( (rep.mIdentityFlags & REPUTATION_IDENTITY_FLAG_PGP_LINKED) && (mBannedPgpIds.find(rep.mOwnerNode) != mBannedPgpIds.end()))
|
|
||||||
{
|
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
|
||||||
#ifdef DEBUG_REPUTATION
|
|
||||||
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << rep.mOwnerNode << " is banned." << std::endl;
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(info.mOverallReputationScore > REPUTATION_ASSESSMENT_THRESHOLD_X1)
|
if(!owner_id.isNull() && (mBannedPgpIds.find(owner_id) != mBannedPgpIds.end()))
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_OK ;
|
{
|
||||||
else
|
#ifdef DEBUG_REPUTATION
|
||||||
|
std::cerr << "p3GxsReputations: identity " << gxsid << " is banned because owner node ID " << owner_id << " is banned." << std::endl;
|
||||||
|
#endif
|
||||||
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
||||||
|
}
|
||||||
|
else if(info.mOverallReputationScore <= REPUTATION_ASSESSMENT_THRESHOLD_X1)
|
||||||
|
info.mAssessment = RsReputations::ASSESSMENT_BAD ;
|
||||||
|
else
|
||||||
|
info.mAssessment = RsReputations::ASSESSMENT_OK ;
|
||||||
|
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << " information present. OwnOp = " << info.mOwnOpinion << ", overall score=" << info.mAssessment << std::endl;
|
std::cerr << " information present. OwnOp = " << info.mOwnOpinion << ", overall score=" << info.mAssessment << std::endl;
|
||||||
|
@ -705,11 +739,12 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, RsReputations::Rep
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3GxsReputation::isIdentityBanned(const RsGxsId &id)
|
bool p3GxsReputation::isIdentityBanned(const RsGxsId &id,const RsPgpId& owner_node)
|
||||||
{
|
{
|
||||||
RsReputations::ReputationInfo info ;
|
RsReputations::ReputationInfo info ;
|
||||||
|
|
||||||
getReputationInfo(id,info) ;
|
if(!getReputationInfo(id,owner_node,info))
|
||||||
|
return false ;
|
||||||
|
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
std::cerr << "isIdentityBanned(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
|
std::cerr << "isIdentityBanned(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
|
||||||
|
|
|
@ -97,8 +97,8 @@ class p3GxsReputation: public p3Service, public p3Config, public RsReputations /
|
||||||
|
|
||||||
/***** Interface for RsReputations *****/
|
/***** Interface for RsReputations *****/
|
||||||
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) ;
|
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) ;
|
||||||
virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) ;
|
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &owner_id, ReputationInfo& info) ;
|
||||||
virtual bool isIdentityBanned(const RsGxsId& id) ;
|
virtual bool isIdentityBanned(const RsGxsId& id, const RsPgpId &owner_node) ;
|
||||||
|
|
||||||
virtual void setNodeAutoBanThreshold(uint32_t n) ;
|
virtual void setNodeAutoBanThreshold(uint32_t n) ;
|
||||||
virtual uint32_t nodeAutoBanThreshold() ;
|
virtual uint32_t nodeAutoBanThreshold() ;
|
||||||
|
|
|
@ -264,7 +264,7 @@ time_t p3IdService::locked_getLastUsageTS(const RsGxsId& gxs_id)
|
||||||
}
|
}
|
||||||
void p3IdService::timeStampKey(const RsGxsId& gxs_id)
|
void p3IdService::timeStampKey(const RsGxsId& gxs_id)
|
||||||
{
|
{
|
||||||
if(rsReputations->isIdentityBanned(gxs_id))
|
if(isBanned(gxs_id))
|
||||||
{
|
{
|
||||||
std::cerr << "(II) p3IdService:timeStampKey(): refusing to time stamp key " << gxs_id << " because it is banned." << std::endl;
|
std::cerr << "(II) p3IdService:timeStampKey(): refusing to time stamp key " << gxs_id << " because it is banned." << std::endl;
|
||||||
return;
|
return;
|
||||||
|
@ -324,7 +324,7 @@ public:
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
const RsGxsId& gxs_id = entry.details.mId ;
|
const RsGxsId& gxs_id = entry.details.mId ;
|
||||||
|
|
||||||
bool is_id_banned = rsReputations->isIdentityBanned(gxs_id) ;
|
bool is_id_banned = rsReputations->isIdentityBanned(gxs_id,entry.details.mPgpId) ;
|
||||||
bool is_own_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID) ;
|
bool is_own_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_IS_OWN_ID) ;
|
||||||
bool is_known_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN) ;
|
bool is_known_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN) ;
|
||||||
bool is_signed_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) ;
|
bool is_signed_id = (bool)(entry.details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) ;
|
||||||
|
@ -524,7 +524,7 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||||
if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4)
|
if(details.mNickname.length() > RSID_MAXIMUM_NICKNAME_SIZE*4)
|
||||||
details.mNickname = "[too long a name]" ;
|
details.mNickname = "[too long a name]" ;
|
||||||
|
|
||||||
rsReputations->getReputationInfo(id,details.mReputation) ;
|
rsReputations->getReputationInfo(id,details.mPgpId,details.mReputation) ;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -536,6 +536,16 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3IdService::isBanned(const RsGxsId &id)
|
||||||
|
{
|
||||||
|
RsIdentityDetails det ;
|
||||||
|
getIdDetails(id,det) ;
|
||||||
|
|
||||||
|
#ifdef DEBUG_REPUTATION
|
||||||
|
std::cerr << "isIdentityBanned(): returning " << (det.mReputation.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
|
||||||
|
#endif
|
||||||
|
return det.mReputation.mAssessment == RsReputations::ASSESSMENT_BAD ;
|
||||||
|
}
|
||||||
|
|
||||||
bool p3IdService::isOwnId(const RsGxsId& id)
|
bool p3IdService::isOwnId(const RsGxsId& id)
|
||||||
{
|
{
|
||||||
|
|
|
@ -274,6 +274,7 @@ virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment,
|
||||||
|
|
||||||
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) ;
|
||||||
virtual bool isARegularContact(const RsGxsId& id) ;
|
virtual bool isARegularContact(const RsGxsId& id) ;
|
||||||
|
virtual bool isBanned(const RsGxsId& id) ;
|
||||||
|
|
||||||
/**************** RsGixs Implementation ***************/
|
/**************** RsGixs Implementation ***************/
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsreputations.h>
|
|
||||||
|
|
||||||
// Data Requests.
|
// Data Requests.
|
||||||
#define IDDETAILSDIALOG_IDDETAILS 1
|
#define IDDETAILSDIALOG_IDDETAILS 1
|
||||||
|
@ -261,7 +260,7 @@ void IdDetailsDialog::insertIdDetails(uint32_t token)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsReputations::ReputationInfo info ;
|
RsReputations::ReputationInfo info ;
|
||||||
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),info) ;
|
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ;
|
||||||
|
|
||||||
ui->neighborNodesOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f));
|
ui->neighborNodesOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f));
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include "util/QtVersion.h"
|
#include "util/QtVersion.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
#include <retroshare/rsreputations.h>
|
|
||||||
#include "retroshare/rsgxsflags.h"
|
#include "retroshare/rsgxsflags.h"
|
||||||
#include "retroshare/rsmsgs.h"
|
#include "retroshare/rsmsgs.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -1360,8 +1359,8 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||||
if (!item)
|
if (!item)
|
||||||
item = new TreeWidgetItem();
|
item = new TreeWidgetItem();
|
||||||
|
|
||||||
RsReputations::ReputationInfo info ;
|
RsIdentityDetails idd ;
|
||||||
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),info) ;
|
rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),idd) ;
|
||||||
|
|
||||||
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE));
|
item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE));
|
||||||
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString()));
|
||||||
|
@ -1372,13 +1371,10 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||||
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ;
|
||||||
|
|
||||||
item->setTextAlignment(RSID_COL_VOTES, Qt::AlignRight);
|
item->setTextAlignment(RSID_COL_VOTES, Qt::AlignRight);
|
||||||
item->setData(RSID_COL_VOTES,Qt::DisplayRole, QString::number(info.mOverallReputationScore - 1.0f,'f',3));
|
item->setData(RSID_COL_VOTES,Qt::DisplayRole, QString::number(idd.mReputation.mOverallReputationScore - 1.0f,'f',3));
|
||||||
|
|
||||||
if(isOwnId)
|
if(isOwnId)
|
||||||
{
|
{
|
||||||
RsIdentityDetails idd ;
|
|
||||||
rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),idd) ;
|
|
||||||
|
|
||||||
QFont font = item->font(RSID_COL_NICKNAME) ;
|
QFont font = item->font(RSID_COL_NICKNAME) ;
|
||||||
|
|
||||||
font.setBold(true) ;
|
font.setBold(true) ;
|
||||||
|
@ -1740,7 +1736,7 @@ void IdDialog::insertIdDetails(uint32_t token)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RsReputations::ReputationInfo info ;
|
RsReputations::ReputationInfo info ;
|
||||||
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),info) ;
|
rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),data.mPgpId,info) ;
|
||||||
|
|
||||||
ui->neighborNodesOpinion_TF->setText(QString::number(info.mFriendAverage - 1.0f));
|
ui->neighborNodesOpinion_TF->setText(QString::number(info.mFriendAverage - 1.0f));
|
||||||
|
|
||||||
|
@ -2021,10 +2017,10 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||||
#endif
|
#endif
|
||||||
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
|
RsGxsId keyId((*it)->text(RSID_COL_KEYID).toStdString());
|
||||||
|
|
||||||
RsReputations::ReputationInfo info ;
|
RsIdentityDetails det ;
|
||||||
rsReputations->getReputationInfo(keyId,info) ;
|
rsIdentity->getIdDetails(keyId,det) ;
|
||||||
|
|
||||||
switch(info.mOwnOpinion)
|
switch(det.mReputation.mOwnOpinion)
|
||||||
{
|
{
|
||||||
case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ;
|
case RsReputations::OPINION_NEGATIVE: ++n_negative_reputations ;
|
||||||
break ;
|
break ;
|
||||||
|
|
|
@ -905,7 +905,7 @@ bool GxsIdDetails::MakeIdDesc(const RsGxsId &id, bool doIcons, QString &str, QLi
|
||||||
|
|
||||||
QString GxsIdDetails::getName(const RsIdentityDetails &details)
|
QString GxsIdDetails::getName(const RsIdentityDetails &details)
|
||||||
{
|
{
|
||||||
if(rsReputations->isIdentityBanned(details.mId))
|
if(rsIdentity->isBanned(details.mId))
|
||||||
return tr("[Banned]") ;
|
return tr("[Banned]") ;
|
||||||
|
|
||||||
QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE);
|
QString name = QString::fromUtf8(details.mNickname.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE);
|
||||||
|
@ -924,7 +924,7 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
|
||||||
QString comment;
|
QString comment;
|
||||||
QString nickname ;
|
QString nickname ;
|
||||||
|
|
||||||
bool banned = rsReputations->isIdentityBanned(details.mId) ;
|
bool banned = rsIdentity->isBanned(details.mId) ;
|
||||||
|
|
||||||
if(details.mNickname.empty())
|
if(details.mNickname.empty())
|
||||||
nickname = tr("[Unknown]") ;
|
nickname = tr("[Unknown]") ;
|
||||||
|
@ -963,7 +963,7 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
|
||||||
{
|
{
|
||||||
QPixmap pix ;
|
QPixmap pix ;
|
||||||
|
|
||||||
if(rsReputations->isIdentityBanned(details.mId))
|
if(rsIdentity->isBanned(details.mId))
|
||||||
{
|
{
|
||||||
icons.clear() ;
|
icons.clear() ;
|
||||||
icons.push_back(QIcon(IMAGE_BANNED)) ;
|
icons.push_back(QIcon(IMAGE_BANNED)) ;
|
||||||
|
|
|
@ -117,14 +117,14 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::updateBannedState()
|
void GxsIdRSTreeWidgetItem::updateBannedState()
|
||||||
{
|
{
|
||||||
if(mBannedState != rsReputations->isIdentityBanned(mId))
|
if(mBannedState != rsIdentity->isBanned(mId))
|
||||||
forceUpdate() ;
|
forceUpdate() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::forceUpdate()
|
void GxsIdRSTreeWidgetItem::forceUpdate()
|
||||||
{
|
{
|
||||||
mIdFound = false;
|
mIdFound = false;
|
||||||
mBannedState = rsReputations->isIdentityBanned(mId) ;
|
mBannedState = rsIdentity->isBanned(mId) ;
|
||||||
|
|
||||||
startProcess();
|
startProcess();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
|
||||||
|
|
||||||
if(mId.isNull())
|
if(mId.isNull())
|
||||||
return RSTreeWidgetItem::data(column, role);
|
return RSTreeWidgetItem::data(column, role);
|
||||||
else if(rsReputations->isIdentityBanned(mId))
|
else if(rsIdentity->isBanned(mId))
|
||||||
pix = QImage(BANNED_IMAGE) ;
|
pix = QImage(BANNED_IMAGE) ;
|
||||||
else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG"))
|
else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG"))
|
||||||
pix = GxsIdDetails::makeDefaultIcon(mId);
|
pix = GxsIdDetails::makeDefaultIcon(mId);
|
||||||
|
|
|
@ -985,7 +985,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
|
||||||
// is flagged with a bad reputation
|
// is flagged with a bad reputation
|
||||||
|
|
||||||
|
|
||||||
bool redacted = rsReputations->isIdentityBanned(msg.mMeta.mAuthorId) ;
|
bool redacted = rsIdentity->isBanned(msg.mMeta.mAuthorId) ;
|
||||||
|
|
||||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
|
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL || (redacted?(GxsIdDetails::ICON_TYPE_REDACTED):0));
|
||||||
item->moveToThread(ui->threadTreeWidget->thread());
|
item->moveToThread(ui->threadTreeWidget->thread());
|
||||||
|
@ -1408,7 +1408,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool redacted = rsReputations->isIdentityBanned(msg.mMeta.mAuthorId) ;
|
bool redacted = rsIdentity->isBanned(msg.mMeta.mAuthorId) ;
|
||||||
|
|
||||||
mStateHelper->setActive(mTokenTypeMessageData, true);
|
mStateHelper->setActive(mTokenTypeMessageData, true);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue