mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-10 03:49:51 -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 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 bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) =0;
|
||||||
virtual ReputationLevel overallReputationLevel(const RsGxsId& id)=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 ;
|
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)
|
bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::Opinion& opinion)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_REPUTATION
|
#ifdef DEBUG_REPUTATION
|
||||||
|
@ -109,6 +109,7 @@ public:
|
|||||||
|
|
||||||
/***** 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 getOwnOpinion(const RsGxsId& key_id, Opinion& op) ;
|
||||||
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) ;
|
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) ;
|
||||||
virtual bool isIdentityBanned(const RsGxsId& id) ;
|
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 << " GxsIdRSTreeWidgetItem::setId(" << id << "," << column << ")";
|
||||||
//std::cerr << std::endl;
|
//std::cerr << std::endl;
|
||||||
|
|
||||||
if (mIdFound) {
|
if (mIdFound)
|
||||||
if (mColumn == column && mId == id) {
|
{
|
||||||
|
if (mColumn == column && mId == id && (mBannedState == rsReputations->isIdentityBanned(mId)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mIdFound = false;
|
mIdFound = false;
|
||||||
@ -110,14 +110,14 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
|
|||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::updateBannedState()
|
void GxsIdRSTreeWidgetItem::updateBannedState()
|
||||||
{
|
{
|
||||||
if(mBannedState != (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE))
|
if(mBannedState != rsReputations->isIdentityBanned(mId))
|
||||||
forceUpdate() ;
|
forceUpdate() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::forceUpdate()
|
void GxsIdRSTreeWidgetItem::forceUpdate()
|
||||||
{
|
{
|
||||||
mIdFound = false;
|
mIdFound = false;
|
||||||
mBannedState = (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE);
|
mBannedState = (rsReputations->isIdentityBanned(mId));
|
||||||
|
|
||||||
startProcess();
|
startProcess();
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ private:
|
|||||||
bool mIdFound;
|
bool mIdFound;
|
||||||
bool mBannedState ;
|
bool mBannedState ;
|
||||||
bool mRetryWhenFailed;
|
bool mRetryWhenFailed;
|
||||||
|
RsReputations::ReputationLevel mReputationLevel ;
|
||||||
uint32_t mIconTypeMask;
|
uint32_t mIconTypeMask;
|
||||||
RsGxsImage mAvatar;
|
RsGxsImage mAvatar;
|
||||||
};
|
};
|
||||||
|
@ -574,15 +574,40 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
|
|||||||
contextMnu.addAction(expandAll);
|
contextMnu.addAction(expandAll);
|
||||||
contextMnu.addAction(collapseAll);
|
contextMnu.addAction(collapseAll);
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
QList<QTreeWidgetItem*> selectedItems = ui->threadTreeWidget->selectedItems();
|
||||||
|
|
||||||
QMenu *submenu1 = contextMnu.addMenu(tr("Author's reputation")) ;
|
if(selectedItems.size() == 1)
|
||||||
submenu1->addAction(flagaspositiveAct);
|
{
|
||||||
submenu1->addAction(flagasneutralAct);
|
QTreeWidgetItem *item = *selectedItems.begin();
|
||||||
submenu1->addAction(flagasnegativeAct);
|
GxsIdRSTreeWidgetItem *gxsIdItem = dynamic_cast<GxsIdRSTreeWidgetItem*>(item);
|
||||||
contextMnu.addAction(showinpeopleAct);
|
|
||||||
|
|
||||||
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());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user