mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-22 20:59:45 -04:00
changed the reputation system to output a level that differentiate your own opinion to your friends opinion
This commit is contained in:
parent
8b9038a028
commit
72fb8f17a9
16 changed files with 173 additions and 94 deletions
|
@ -880,20 +880,13 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
|||
else
|
||||
{
|
||||
|
||||
// now check reputation of the message author
|
||||
float reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT;
|
||||
|
||||
if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN))
|
||||
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM;
|
||||
else if( (signFlag & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) && !(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED))
|
||||
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_ANTI_SPAM;
|
||||
else
|
||||
reputation_threshold = RsReputations::REPUTATION_THRESHOLD_DEFAULT;
|
||||
|
||||
if(details.mReputation.mOverallReputationScore < reputation_threshold)
|
||||
// now check reputation of the message author. The reputation will need to be at least as high as this value for the msg to validate.
|
||||
// At validation step, we accept all messages, except the ones signed by locally rejected identities.
|
||||
|
||||
if(details.mReputation.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef GEN_EXCH_DEBUG
|
||||
std::cerr << "RsGenExchange::validateMsg(): message from " << metaData.mAuthorId << ", rejected because reputation score (" << details.mReputation.mOverallReputationScore <<") is below the accepted threshold (" << reputation_threshold << ")" << std::endl;
|
||||
std::cerr << "RsGenExchange::validateMsg(): message from " << metaData.mAuthorId << ", rejected because reputation score (" << details.mReputation.mOverallReputationLevel <<") is below the accepted threshold (" << reputation_threshold << ")" << std::endl;
|
||||
#endif
|
||||
idValidate = false ;
|
||||
}
|
||||
|
@ -903,7 +896,7 @@ int RsGenExchange::validateMsg(RsNxsMsg *msg, const uint32_t& grpFlag, const uin
|
|||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -2810,16 +2810,13 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
if(reqListSize < MAX_REQLIST_SIZE && msgIdSet.find(msgId) == msgIdSet.end())
|
||||
{
|
||||
|
||||
// if reputation is in reputations cache then proceed
|
||||
// or if there isn't an author (note as author requirement is
|
||||
// enforced at service level, if no author is needed then reputation
|
||||
// filtering is optional)
|
||||
bool noAuthor = syncItem->authorId.isNull();
|
||||
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", reqlist size=" << reqListSize << ", message not present." ;
|
||||
#endif
|
||||
// grp meta must be present if author present
|
||||
|
||||
if(!noAuthor && grpMeta == NULL)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
|
@ -2828,7 +2825,14 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
continue;
|
||||
}
|
||||
|
||||
if(rsIdentity && rsIdentity->isBanned(syncItem->authorId))
|
||||
// The algorithm on request of message is:
|
||||
//
|
||||
// - always re-check for author ban level
|
||||
// - if author is locally banned, do not download.
|
||||
// - if author is not locally banned, download, whatever friends' opinion might be.
|
||||
|
||||
#warning Update the code below to correctly send/recv dependign on reputation
|
||||
if(rsIdentity && rsIdentity->overallReputationLevel(syncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
|
||||
|
@ -2844,7 +2848,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
continue ;
|
||||
}
|
||||
|
||||
|
||||
#ifdef TO_BE_REMOVED
|
||||
if(mReputations->haveReputation(syncItem->authorId) || noAuthor)
|
||||
{
|
||||
GixsReputation rep;
|
||||
|
@ -2859,17 +2863,20 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
// at genexchange side of things
|
||||
if(rep.score >= (int)grpMeta->mReputationCutOff || noAuthor)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", passed! Adding message to req list." << std::endl;
|
||||
#endif
|
||||
RsNxsSyncMsgItem* msgItem = new RsNxsSyncMsgItem(mServType);
|
||||
msgItem->grpId = grpId;
|
||||
msgItem->msgId = msgId;
|
||||
msgItem->flag = RsNxsSyncMsgItem::FLAG_REQUEST;
|
||||
msgItem->transactionNumber = transN;
|
||||
msgItem->PeerId(peerFrom);
|
||||
reqList.push_back(msgItem);
|
||||
++reqListSize ;
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", passed! Adding message to req list." << std::endl;
|
||||
#endif
|
||||
RsNxsSyncMsgItem* msgItem = new RsNxsSyncMsgItem(mServType);
|
||||
msgItem->grpId = grpId;
|
||||
msgItem->msgId = msgId;
|
||||
msgItem->flag = RsNxsSyncMsgItem::FLAG_REQUEST;
|
||||
msgItem->transactionNumber = transN;
|
||||
msgItem->PeerId(peerFrom);
|
||||
reqList.push_back(msgItem);
|
||||
++reqListSize ;
|
||||
|
||||
#ifdef TO_BE_REMOVED
|
||||
}
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
else
|
||||
|
@ -2889,6 +2896,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
entry.mMsgId = syncItem->msgId;
|
||||
toVet.push_back(entry);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
else
|
||||
|
@ -3061,13 +3069,14 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
}
|
||||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
|
||||
if(!grpSyncItem->authorId.isNull() && rsIdentity && rsIdentity->isBanned(grpSyncItem->authorId))
|
||||
{
|
||||
#warning Update the code below to correctly send/recv dependign on reputation
|
||||
if(!grpSyncItem->authorId.isNull() && rsIdentity && rsIdentity->overallReputationLevel(grpSyncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#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;
|
||||
#endif
|
||||
continue ;
|
||||
}
|
||||
continue ;
|
||||
}
|
||||
|
||||
if( (mGrpAutoSync && !haveItem) || latestVersion)
|
||||
{
|
||||
|
|
|
@ -171,7 +171,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
GXSUTIL_DEBUG() << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
|
||||
#endif
|
||||
|
||||
if(rsIdentity!=NULL && !rsIdentity->isBanned(grp->metaData->mAuthorId))
|
||||
if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId,grp->grpId)) ;
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ bool RsGxsIntegrityCheck::check()
|
|||
#ifdef DEBUG_GXSUTIL
|
||||
GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
|
||||
#endif
|
||||
if(rsIdentity!=NULL && !rsIdentity->isBanned(msg->metaData->mAuthorId))
|
||||
if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,msg->metaData->mGroupId)) ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue