enabled bannign button in forums, and disable message passing for banned users

This commit is contained in:
csoler 2015-10-11 21:41:35 -04:00
parent e309dd6fed
commit 1a76bea6ff
9 changed files with 45 additions and 25 deletions

View File

@ -1997,7 +1997,13 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
std::cerr << ", no group meta found. Givign up." << std::endl; std::cerr << ", no group meta found. Givign up." << std::endl;
continue; continue;
} }
if(rsReputations->isIdentityBanned(syncItem->authorId))
{
std::cerr << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
continue ;
}
if(mReputations->haveReputation(syncItem->authorId) || noAuthor) if(mReputations->haveReputation(syncItem->authorId) || noAuthor)
{ {
GixsReputation rep; GixsReputation rep;
@ -2010,7 +2016,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
// if author is required for this message, it will simply get dropped // if author is required for this message, it will simply get dropped
// at genexchange side of things // at genexchange side of things
if(rsReputations->isIdentityOk(syncItem->authorId) && rep.score > (int)grpMeta->mReputationCutOff || noAuthor) if(rep.score > (int)grpMeta->mReputationCutOff || noAuthor)
{ {
#ifdef NXS_NET_DEBUG #ifdef NXS_NET_DEBUG
std::cerr << ", passed! Adding message to req list." << std::endl; std::cerr << ", passed! Adding message to req list." << std::endl;
@ -2211,7 +2217,13 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
haveItem = true; haveItem = true;
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs; latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
} }
if(rsReputations->isIdentityBanned(grpSyncItem->authorId))
{
std::cerr << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
continue ;
}
if( (mGrpAutoSync && !haveItem) || latestVersion) if( (mGrpAutoSync && !haveItem) || latestVersion)
{ {
// determine if you need to check reputation // determine if you need to check reputation
@ -2226,7 +2238,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
GixsReputation rep; GixsReputation rep;
mReputations->getReputation(grpSyncItem->authorId, rep); mReputations->getReputation(grpSyncItem->authorId, rep);
if(rep.score >= GIXS_CUT_OFF && rsReputations->isIdentityOk(grpSyncItem->authorId)) if(rep.score >= GIXS_CUT_OFF)
{ {
addGroupItemToList(tr, grpId, transN, reqList); addGroupItemToList(tr, grpId, transN, reqList);
std::cerr << " reputation cut off: limit=" << GIXS_CUT_OFF << " value=" << rep.score << ": allowed." << std::endl; std::cerr << " reputation cut off: limit=" << GIXS_CUT_OFF << " value=" << rep.score << ": allowed." << std::endl;

View File

@ -32,6 +32,7 @@
#include "retroshare/rstokenservice.h" #include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsreputations.h"
#include "retroshare/rsids.h" #include "retroshare/rsids.h"
#include "serialiser/rstlvimage.h" #include "serialiser/rstlvimage.h"
#include "retroshare/rsgxscommon.h" #include "retroshare/rsgxscommon.h"
@ -158,8 +159,7 @@ class RsIdentityDetails
{ {
public: public:
RsIdentityDetails() RsIdentityDetails()
:mIsOwnId(false), mPgpLinked(false), mPgpKnown(false), :mIsOwnId(false), mPgpLinked(false), mPgpKnown(false), mLastUsageTS(0) { return; }
mReputation(), mLastUsageTS(0) { return; }
RsGxsId mId; RsGxsId mId;
@ -175,9 +175,12 @@ public:
// Recogn details. // Recogn details.
std::list<RsRecognTag> mRecognTags; std::list<RsRecognTag> mRecognTags;
// reputation details. // Cyril: Reputation details. At some point we might want to merge information
GxsReputation mReputation; // between the two into a single global score. Since the old reputation system
bool mBanned ; // is not finished yet, I leave this in place. We should decide what to do with it.
GxsReputation mReputation_oldSystem; // this is the old "mReputation" field, which apparently is not used.
RsReputations::ReputationInfo mReputation;
// avatar // avatar
RsGxsImage mAvatar ; RsGxsImage mAvatar ;

View File

@ -48,9 +48,9 @@ public:
virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) =0 ; virtual bool getReputationInfo(const RsGxsId& id,ReputationInfo& info) =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 ASSESSMENT_OK // it basically returns true if assessment is not ASSESSMENT_OK
virtual bool isIdentityOk(const RsGxsId& id) =0; virtual bool isIdentityBanned(const RsGxsId& id) =0;
}; };
// To access reputations from anywhere // To access reputations from anywhere

View File

@ -550,16 +550,16 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, RsReputations::Rep
return true ; return true ;
} }
bool p3GxsReputation::isIdentityOk(const RsGxsId &id) bool p3GxsReputation::isIdentityBanned(const RsGxsId &id)
{ {
RsReputations::ReputationInfo info ; RsReputations::ReputationInfo info ;
getReputationInfo(id,info) ; getReputationInfo(id,info) ;
#ifdef DEBUG_REPUTATION #ifdef DEBUG_REPUTATION
std::cerr << "isIdentityOk(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_OK) << " for GXS id " << id << std::endl; std::cerr << "isIdentityBanned(): returning " << (info.mAssessment == RsReputations::ASSESSMENT_BAD) << " for GXS id " << id << std::endl;
#endif #endif
return info.mAssessment == RsReputations::ASSESSMENT_OK ; return info.mAssessment == RsReputations::ASSESSMENT_BAD ;
} }
bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::Opinion& opinion) bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::Opinion& opinion)

View File

@ -90,7 +90,7 @@ 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,ReputationInfo& info) ;
virtual bool isIdentityOk(const RsGxsId& id) ; virtual bool isIdentityBanned(const RsGxsId& id) ;
/***** overloaded from p3Service *****/ /***** overloaded from p3Service *****/
virtual int tick(); virtual int tick();

View File

@ -412,6 +412,8 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
// one utf8 symbol can be at most 4 bytes long - would be better to measure real unicode length !!! // one utf8 symbol can be at most 4 bytes long - would be better to measure real unicode length !!!
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) ;
return true; return true;
} }
@ -421,6 +423,9 @@ bool p3IdService:: getIdDetails(const RsGxsId &id, RsIdentityDetails &details)
{ {
details = data.details; details = data.details;
details.mLastUsageTS = locked_getLastUsageTS(id) ; details.mLastUsageTS = locked_getLastUsageTS(id) ;
rsReputations->getReputationInfo(id,details.mReputation) ;
return true; return true;
} }
} }
@ -831,7 +836,7 @@ bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep)
if (mPublicKeyCache.fetch(id, data)) if (mPublicKeyCache.fetch(id, data))
{ {
rep.id = id; rep.id = id;
rep.score = data.details.mReputation.mOverallScore; rep.score = 0;//data.details.mReputation.mOverallScore;
#ifdef DEBUG_IDS #ifdef DEBUG_IDS
std::cerr << "p3IdService::getReputation() id: "; std::cerr << "p3IdService::getReputation() id: ";
std::cerr << id.toStdString() << " score: " << std::cerr << id.toStdString() << " score: " <<
@ -1669,14 +1674,14 @@ void RsGxsIdCache::updateServiceString(std::string serviceString)
} }
// copy over Reputation scores. // copy over Reputation scores.
details.mReputation = ssdata.score.rep; //details.mReputation = ssdata.score.rep;
} }
else else
{ {
details.mPgpKnown = false; details.mPgpKnown = false;
details.mPgpId.clear(); details.mPgpId.clear();
details.mReputation.updateIdScore(false, false); //details.mReputation.updateIdScore(false, false);
details.mReputation.update(); //details.mReputation.update();
} }
} }

View File

@ -878,7 +878,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->isIdentityOk(details.mId)) if(rsReputations->isIdentityBanned(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);
@ -897,7 +897,7 @@ QString GxsIdDetails::getComment(const RsIdentityDetails &details)
QString comment; QString comment;
QString nickname ; QString nickname ;
bool banned = !rsReputations->isIdentityOk(details.mId) ; bool banned = rsReputations->isIdentityBanned(details.mId) ;
if(details.mNickname.empty()) if(details.mNickname.empty())
nickname = tr("[Unknown]") ; nickname = tr("[Unknown]") ;
@ -936,7 +936,7 @@ void GxsIdDetails::getIcons(const RsIdentityDetails &details, QList<QIcon> &icon
{ {
QPixmap pix ; QPixmap pix ;
if(!rsReputations->isIdentityOk(details.mId)) if(rsReputations->isIdentityBanned(details.mId))
{ {
icons.clear() ; icons.clear() ;
icons.push_back(QIcon(IMAGE_BANNED)) ; icons.push_back(QIcon(IMAGE_BANNED)) ;

View File

@ -153,7 +153,7 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
QString t = RSTreeWidgetItem::data(column, role).toString(); QString t = RSTreeWidgetItem::data(column, role).toString();
QImage pix; QImage pix;
if(!rsReputations->isIdentityOk(mId)) if(rsReputations->isIdentityBanned(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);

View File

@ -901,7 +901,7 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
// is flagged with a bad reputation // is flagged with a bad reputation
bool redacted = !rsReputations->isIdentityOk(msg.mMeta.mAuthorId) ; bool redacted = rsReputations->isIdentityBanned(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());
@ -1320,7 +1320,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
return; return;
} }
bool redacted = !rsReputations->isIdentityOk(msg.mMeta.mAuthorId) ; bool redacted = rsReputations->isIdentityBanned(msg.mMeta.mAuthorId) ;
mStateHelper->setActive(mTokenTypeMessageData, true); mStateHelper->setActive(mTokenTypeMessageData, true);