added removal of messages frm banned users

This commit is contained in:
csoler 2015-10-10 18:27:15 -04:00
parent 59d2ca9c3d
commit 68ca57ce75
5 changed files with 55 additions and 20 deletions

View file

@ -30,6 +30,7 @@
#include "rsgxsnetservice.h" #include "rsgxsnetservice.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"
@ -2009,7 +2010,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(rep.score > (int)grpMeta->mReputationCutOff || noAuthor) if(rsReputations->isIdentityOk(syncItem->authorId) && 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;
@ -2225,7 +2226,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) if(rep.score >= GIXS_CUT_OFF && rsReputations->isIdentityOk(grpSyncItem->authorId))
{ {
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

@ -567,6 +567,12 @@ bool p3GxsReputation::setOwnOpinion(const RsGxsId& gxsid, const RsReputations::O
#ifdef DEBUG_REPUTATION #ifdef DEBUG_REPUTATION
std::cerr << "setOwnOpinion(): for GXS id " << gxsid << " to " << opinion << std::endl; std::cerr << "setOwnOpinion(): for GXS id " << gxsid << " to " << opinion << std::endl;
#endif #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 *******/ RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
std::map<RsGxsId, Reputation>::iterator rit; std::map<RsGxsId, Reputation>::iterator rit;

View file

@ -49,10 +49,11 @@ class GxsIdDetails : public QObject
Q_OBJECT Q_OBJECT
public: public:
static const int ICON_TYPE_AVATAR = 0x0001 ; static const int ICON_TYPE_AVATAR = 0x0001 ;
static const int ICON_TYPE_PGP = 0x0002 ; static const int ICON_TYPE_PGP = 0x0002 ;
static const int ICON_TYPE_RECOGN = 0x0004 ; static const int ICON_TYPE_RECOGN = 0x0004 ;
static const int ICON_TYPE_ALL = 0x0007 ; static const int ICON_TYPE_ALL = 0x0007 ;
static const int ICON_TYPE_REDACTED= 0x0008 ;
GxsIdDetails(); GxsIdDetails();
virtual ~GxsIdDetails(); virtual ~GxsIdDetails();

View file

@ -83,6 +83,7 @@
#define ROLE_THREAD_READCHILDREN Qt::UserRole + 4 #define ROLE_THREAD_READCHILDREN Qt::UserRole + 4
#define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5 #define ROLE_THREAD_UNREADCHILDREN Qt::UserRole + 5
#define ROLE_THREAD_SORT Qt::UserRole + 6 #define ROLE_THREAD_SORT Qt::UserRole + 6
#define ROLE_THREAD_REDACTED Qt::UserRole + 7
#define ROLE_THREAD_COUNT 4 #define ROLE_THREAD_COUNT 4
@ -408,7 +409,8 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/)
QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply with private message"), &contextMnu); QAction *replyauthorAct = new QAction(QIcon(IMAGE_MESSAGEREPLY), tr("Reply with private message"), &contextMnu);
connect(replyauthorAct, SIGNAL(triggered()), this, SLOT(replytomessage())); connect(replyauthorAct, SIGNAL(triggered()), this, SLOT(replytomessage()));
QAction *flagasbadAct = new QAction(QIcon(IMAGE_BIOHAZARD), tr("Flag this person as bad"), &contextMnu); QAction *flagasbadAct = new QAction(QIcon(IMAGE_BIOHAZARD), tr("Flag the author as bad"), &contextMnu);
flagasbadAct->setToolTip(tr("This will block/hide messages from this person, and notify neighbor nodes.")) ;
connect(flagasbadAct, SIGNAL(triggered()), this, SLOT(flagpersonasbad())); connect(flagasbadAct, SIGNAL(triggered()), this, SLOT(flagpersonasbad()));
QAction *newthreadAct = new QAction(QIcon(IMAGE_MESSAGE), tr("Start New Thread"), &contextMnu); QAction *newthreadAct = new QAction(QIcon(IMAGE_MESSAGE), tr("Start New Thread"), &contextMnu);
@ -893,12 +895,21 @@ void GxsForumThreadWidget::fillThreadStatus(QString text)
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn) QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
{ {
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole,GxsIdDetails::ICON_TYPE_ALL); // Early check for a message that should be hidden because its author
// is flagged with a bad reputation
bool redacted = !rsReputations->isIdentityOk(msg.mMeta.mAuthorId) ;
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());
QString text; QString text;
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str())); if(redacted)
item->setText(COLUMN_THREAD_TITLE, tr("[ ... Redacted message ... ]"));
else
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
QDateTime qtime; QDateTime qtime;
QString sort; QString sort;
@ -968,9 +979,9 @@ QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForum
} }
#endif #endif
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msg.mMeta.mMsgStatus); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_STATUS, msg.mMeta.mMsgStatus);
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, false); item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_MISSING, false);
item->setData(COLUMN_THREAD_DATA, ROLE_THREAD_REDACTED, redacted);
return item; return item;
} }
@ -1308,6 +1319,8 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
return; return;
} }
bool redacted = !rsReputations->isIdentityOk(msg.mMeta.mAuthorId) ;
mStateHelper->setActive(mTokenTypeMessageData, true); mStateHelper->setActive(mTokenTypeMessageData, true);
QTreeWidgetItem *item = ui->threadTreeWidget->currentItem(); QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
@ -1341,9 +1354,18 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
ui->by_text_label->show() ; ui->by_text_label->show() ;
ui->by_label->show() ; ui->by_label->show() ;
QString extraTxt = RsHtml().formatText(ui->postText->document(), QString::fromUtf8(msg.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); if(redacted)
{
QString extraTxt = tr("<p><font color=\"#ff0000\"><b>The author of this message (with ID %1) is banned.</b>").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ;
extraTxt += "<UL><li></b><font color=\"#ff0000\">Messages from this author are not forwarded. </font></b></li>" ;
extraTxt += "<UL><li></b><font color=\"#ff0000\">Messages from this author are replaced by this text. </font></b></li>" ;
ui->postText->setHtml(extraTxt);
}
else
{
QString extraTxt = RsHtml().formatText(ui->postText->document(), QString::fromUtf8(msg.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS);
ui->postText->setHtml(extraTxt); ui->postText->setHtml(extraTxt);
}
//ui->threadTitle->setText(QString::fromUtf8(msg.mMeta.mMsgName.c_str())); //ui->threadTitle->setText(QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
} }
@ -1694,13 +1716,18 @@ static QString buildReplyHeader(const RsMsgMetaData &meta)
void GxsForumThreadWidget::flagpersonasbad() void GxsForumThreadWidget::flagpersonasbad()
{ {
if (groupId().isNull() || mThreadId.isNull()) { // no need to use the token system for that, since we just need to find out the author's name, which is in the item.
QMessageBox::information(this, tr("RetroShare"),tr("You cant reply to a non-existant Message"));
return;
}
// Get Message ... then complete replyMessageData(). QTreeWidgetItem *item = ui->threadTreeWidget->currentItem();
rsReputations->setOwnOpinion(RsGxsId(groupId()),RsReputations::OPINION_NEGATIVE) ;
std::cerr << "Author string: \"" << item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString()<< std::endl;
RsGxsId gxsId(item->data(COLUMN_THREAD_DATA, ROLE_THREAD_AUTHOR).toString().toStdString());
// Get Message ... then complete replyMessageData().
std::cerr << "GxsForumThreadWidget::flagpersonasbad(): setting opinion for peer " << gxsId << " to " << RsReputations::OPINION_NEGATIVE << std::endl;
rsReputations->setOwnOpinion(gxsId,RsReputations::OPINION_NEGATIVE) ;
emit groupChanged(this);
} }
void GxsForumThreadWidget::replytomessage() void GxsForumThreadWidget::replytomessage()

View file

@ -66,7 +66,7 @@ protected:
/* GxsMessageFrameWidget */ /* GxsMessageFrameWidget */
virtual void setAllMessagesReadDo(bool read, uint32_t &token); virtual void setAllMessagesReadDo(bool read, uint32_t &token);
private slots: private slots:
/** Create the context popup menu and it's submenus */ /** Create the context popup menu and it's submenus */
void threadListCustomPopupMenu(QPoint point); void threadListCustomPopupMenu(QPoint point);