mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-04 09:05:34 -05:00
disallow to ban your own identity in forums, and make opinions show up as a function ofwhat the ID opinion already is
This commit is contained in:
parent
17cf6607f8
commit
df94de9142
@ -61,6 +61,7 @@ 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;
|
||||
|
||||
|
@ -959,6 +959,29 @@ bool p3GxsReputation::isIdentityBanned(const RsGxsId &id)
|
||||
return info.mOverallReputationLevel == RsReputations::REPUTATION_LOCALLY_NEGATIVE ;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::getOwnOpinion(const RsGxsId& gxsid, RsReputations::Opinion& opinion)
|
||||
{
|
||||
#ifdef DEBUG_REPUTATION
|
||||
std::cerr << "setOwnOpinion(): for GXS id " << gxsid << " to " << opinion << std::endl;
|
||||
#endif
|
||||
if(gxsid.isNull())
|
||||
{
|
||||
std::cerr << " ID " << gxsid << " is rejected. Look for a bug in calling method." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||
|
||||
std::map<RsGxsId, Reputation>::iterator rit = mReputations.find(gxsid);
|
||||
|
||||
if(rit != mReputations.end())
|
||||
opinion = RsReputations::Opinion(rit->second.mOwnOpinion) ;
|
||||
else
|
||||
opinion = RsReputations::OPINION_NEUTRAL ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::Opinion& opinion)
|
||||
{
|
||||
#ifdef DEBUG_REPUTATION
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
|
||||
/***** 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 isIdentityBanned(const RsGxsId& id) ;
|
||||
|
||||
|
@ -93,10 +93,10 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
|
||||
//std::cerr << " GxsIdRSTreeWidgetItem::setId(" << id << "," << column << ")";
|
||||
//std::cerr << std::endl;
|
||||
|
||||
if (mIdFound) {
|
||||
if (mColumn == column && mId == id) {
|
||||
if (mIdFound)
|
||||
{
|
||||
if (mColumn == column && mId == id && (mBannedState == rsReputations->isIdentityBanned(mId)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mIdFound = false;
|
||||
@ -110,14 +110,14 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
|
||||
|
||||
void GxsIdRSTreeWidgetItem::updateBannedState()
|
||||
{
|
||||
if(mBannedState != (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE))
|
||||
if(mBannedState != rsReputations->isIdentityBanned(mId))
|
||||
forceUpdate() ;
|
||||
}
|
||||
|
||||
void GxsIdRSTreeWidgetItem::forceUpdate()
|
||||
{
|
||||
mIdFound = false;
|
||||
mBannedState = (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE);
|
||||
mBannedState = (rsReputations->isIdentityBanned(mId));
|
||||
|
||||
startProcess();
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ private:
|
||||
bool mIdFound;
|
||||
bool mBannedState ;
|
||||
bool mRetryWhenFailed;
|
||||
RsReputations::ReputationLevel mReputationLevel ;
|
||||
uint32_t mIconTypeMask;
|
||||
RsGxsImage mAvatar;
|
||||
};
|
||||
|
@ -574,15 +574,40 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
||||
contextMnu.addAction(expandAll);
|
||||
contextMnu.addAction(collapseAll);
|
||||
|
||||
contextMnu.addSeparator();
|
||||
QList<QTreeWidgetItem*> selectedItems = ui->threadTreeWidget->selectedItems();
|
||||
|
||||
QMenu *submenu1 = contextMnu.addMenu(tr("Author's reputation")) ;
|
||||
submenu1->addAction(flagaspositiveAct);
|
||||
submenu1->addAction(flagasneutralAct);
|
||||
submenu1->addAction(flagasnegativeAct);
|
||||
contextMnu.addAction(showinpeopleAct);
|
||||
if(selectedItems.size() == 1)
|
||||
{
|
||||
QTreeWidgetItem *item = *selectedItems.begin();
|
||||
GxsIdRSTreeWidgetItem *gxsIdItem = dynamic_cast<GxsIdRSTreeWidgetItem*>(item);
|
||||
|
||||
contextMnu.addAction(replyauthorAct);
|
||||
RsGxsId author_id;
|
||||
if(gxsIdItem && gxsIdItem->getId(author_id))
|
||||
{
|
||||
std::cerr << "Author is: " << author_id << std::endl;
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
RsReputations::Opinion op ;
|
||||
|
||||
if(!rsIdentity->isOwnId(author_id) && rsReputations->getOwnOpinion(author_id,op))
|
||||
{
|
||||
QMenu *submenu1 = contextMnu.addMenu(tr("Author's reputation")) ;
|
||||
|
||||
if(op != RsReputations::OPINION_POSITIVE)
|
||||
submenu1->addAction(flagaspositiveAct);
|
||||
|
||||
if(op != RsReputations::OPINION_NEUTRAL)
|
||||
submenu1->addAction(flagasneutralAct);
|
||||
|
||||
if(op != RsReputations::OPINION_NEGATIVE)
|
||||
submenu1->addAction(flagasnegativeAct);
|
||||
}
|
||||
|
||||
contextMnu.addAction(showinpeopleAct);
|
||||
contextMnu.addAction(replyauthorAct);
|
||||
}
|
||||
}
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user