added update for forum messages list when an author gets banned

This commit is contained in:
csoler 2015-10-12 14:03:53 -04:00
parent 5a3756f058
commit 7dc59845e9
3 changed files with 39 additions and 25 deletions

View File

@ -37,7 +37,6 @@
/**** /****
* #define DEBUG_REPUTATION 1 * #define DEBUG_REPUTATION 1
****/ ****/
#define DEBUG_REPUTATION 1
/************ IMPLEMENTATION NOTES ********************************* /************ IMPLEMENTATION NOTES *********************************
* *
@ -130,7 +129,7 @@ static const uint32_t UPPER_LIMIT = 2; // used to
static const float REPUTATION_ASSESSMENT_THRESHOLD_X1 = 0.5f ; // reputation under which the peer gets killed static const float REPUTATION_ASSESSMENT_THRESHOLD_X1 = 0.5f ; // reputation under which the peer gets killed
static const int kMaximumPeerAge = 180; // half a year. static const int kMaximumPeerAge = 180; // half a year.
static const int kMaximumSetSize = 100; // max set of updates to send at once. static const int kMaximumSetSize = 100; // max set of updates to send at once.
static const int ACTIVE_FRIENDS_UPDATE_PERIOD = 60;//600 ;// 10 minutes static const int ACTIVE_FRIENDS_UPDATE_PERIOD = 600 ; // 10 minutes
static const int ACTIVE_FRIENDS_ONLINE_DELAY = 86400*7 ; // 1 week. static const int ACTIVE_FRIENDS_ONLINE_DELAY = 86400*7 ; // 1 week.
@ -167,23 +166,25 @@ int p3GxsReputation::tick()
{ {
processIncoming(); processIncoming();
sendPackets(); sendPackets();
time_t now = time(NULL); time_t now = time(NULL);
if(mLastActiveFriendsUpdate + ACTIVE_FRIENDS_UPDATE_PERIOD < now) if(mLastActiveFriendsUpdate + ACTIVE_FRIENDS_UPDATE_PERIOD < now)
{ {
updateActiveFriends() ; updateActiveFriends() ;
mLastActiveFriendsUpdate = now ; cleanup() ;
}
mLastActiveFriendsUpdate = now ;
}
#ifdef DEBUG_REPUTATION #ifdef DEBUG_REPUTATION
static time_t last_debug_print = time(NULL) ; static time_t last_debug_print = time(NULL) ;
if(now > 10+last_debug_print) if(now > 10+last_debug_print)
{ {
last_debug_print = now ; last_debug_print = now ;
debug_print() ; debug_print() ;
} }
#endif #endif
return 0; return 0;
} }
@ -193,6 +194,16 @@ int p3GxsReputation::status()
return 1; return 1;
} }
void p3GxsReputation::cleanup()
{
// remove opinions from friends that havn't been seen online for more than the specified delay
#ifdef DEBUG_REPUTATION
std::cerr << "p3GxsReputation::cleanup() " << std::endl;
#endif
std::cerr << __PRETTY_FUNCTION__ << ": not implemented. TODO!" << std::endl;
}
void p3GxsReputation::updateActiveFriends() void p3GxsReputation::updateActiveFriends()
{ {
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
@ -347,8 +358,10 @@ bool p3GxsReputation::SendReputations(RsGxsReputationRequestItem *request)
if (count > kMaximumSetSize) if (count > kMaximumSetSize)
{ {
#ifdef DEBUG_REPUTATION
std::cerr << "p3GxsReputation::SendReputations() Sending Full Packet"; std::cerr << "p3GxsReputation::SendReputations() Sending Full Packet";
std::cerr << std::endl; std::cerr << std::endl;
#endif
sendItem(pkt); sendItem(pkt);
@ -360,8 +373,10 @@ bool p3GxsReputation::SendReputations(RsGxsReputationRequestItem *request)
if (!pkt->mOpinions.empty()) if (!pkt->mOpinions.empty())
{ {
#ifdef DEBUG_REPUTATION
std::cerr << "p3GxsReputation::SendReputations() Sending Final Packet"; std::cerr << "p3GxsReputation::SendReputations() Sending Final Packet";
std::cerr << std::endl; std::cerr << std::endl;
#endif
sendItem(pkt); sendItem(pkt);
} }
@ -370,8 +385,10 @@ bool p3GxsReputation::SendReputations(RsGxsReputationRequestItem *request)
delete pkt; delete pkt;
} }
#ifdef DEBUG_REPUTATION
std::cerr << "p3GxsReputation::SendReputations() Total Count: " << totalcount; std::cerr << "p3GxsReputation::SendReputations() Total Count: " << totalcount;
std::cerr << std::endl; std::cerr << std::endl;
#endif
return true; return true;
} }

View File

@ -117,13 +117,12 @@ class p3GxsReputation: public p3Service, public p3Config, public RsReputations /
// internal update of data. Takes care of cleaning empty boxes. // internal update of data. Takes care of cleaning empty boxes.
void locked_updateOpinion(const RsPeerId &from, const RsGxsId &about, RsReputations::Opinion op); void locked_updateOpinion(const RsPeerId &from, const RsGxsId &about, RsReputations::Opinion op);
bool loadReputationSet(RsGxsReputationSetItem *item, const std::set<RsPeerId> &peerSet);
bool loadReputationSet(RsGxsReputationSetItem *item, int sendPackets();
const std::set<RsPeerId> &peerSet); void cleanup();
int sendPackets();
void sendReputationRequests(); void sendReputationRequests();
int sendReputationRequest(RsPeerId peerid); int sendReputationRequest(RsPeerId peerid);
void debug_print() ; void debug_print() ;
private: private:

View File

@ -1363,7 +1363,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
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())) ; 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 += tr("<UL><li><b><font color=\"#ff0000\">Messages from this author are not forwarded. </font></b></li>") ; extraTxt += tr("<UL><li><b><font color=\"#ff0000\">Messages from this author are not forwarded. </font></b></li>") ;
extraTxt += tr("<li><b><font color=\"#ff0000\">Messages from this author are replaced by this text. </font></b></li></ul>") ; extraTxt += tr("<li><b><font color=\"#ff0000\">Messages from this author are replaced by this text. </font></b></li></ul>") ;
extraTxt += tr("<p><font color=\"#ff0000\">You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.</font></p>") ; extraTxt += tr("<p><b><font color=\"#ff0000\">You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.</font></b></p>") ;
ui->postText->setHtml(extraTxt); ui->postText->setHtml(extraTxt);
} }
@ -1746,7 +1746,6 @@ void GxsForumThreadWidget::flagpersonasbad()
uint32_t token; uint32_t token;
mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeBanAuthor); mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeBanAuthor);
} }
void GxsForumThreadWidget::replytomessage() void GxsForumThreadWidget::replytomessage()
@ -2055,8 +2054,7 @@ void GxsForumThreadWidget::loadMsgData_BanAuthor(const uint32_t &token)
std::cerr << "GxsForumThreadWidget::loadMsgData_ReplyMessage() ERROR Missing Message Data..."; std::cerr << "GxsForumThreadWidget::loadMsgData_ReplyMessage() ERROR Missing Message Data...";
std::cerr << std::endl; std::cerr << std::endl;
} }
updateDisplay(true) ;
requestGroupData() ;
} }
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/
/*********************** **** **** **** ***********************/ /*********************** **** **** **** ***********************/