added display of warning for non forwarded posts

This commit is contained in:
csoler 2016-12-26 15:59:53 +01:00
parent 811d084dfa
commit 742a7648a4
12 changed files with 160 additions and 54 deletions

View file

@ -1614,6 +1614,10 @@ uint32_t RsGenExchange::getDefaultSyncPeriod()
}
}
RsReputations::ReputationLevel RsGenExchange::minReputationForForwardingMessages(uint32_t group_sign_flags,uint32_t identity_sign_flags)
{
return RsNetworkExchangeService::minReputationForForwardingMessages(group_sign_flags,identity_sign_flags);
}
uint32_t RsGenExchange::getSyncPeriod(const RsGxsGroupId& grpId)
{
RS_STACK_MUTEX(mGenMtx) ;

View file

@ -658,6 +658,7 @@ public:
uint16_t serviceType() const { return mServType ; }
uint32_t serviceFullType() const { return ((uint32_t)mServType << 8) + (((uint32_t) RS_PKT_VERSION_SERVICE) << 24); }
virtual RsReputations::ReputationLevel minReputationForForwardingMessages(uint32_t group_sign_flags,uint32_t identity_flags);
protected:
/** Notifications **/

View file

@ -4210,18 +4210,10 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
if(canSendMsgIds(msgMetas, *grpMeta, peer, should_encrypt_to_this_circle_id))
{
RsReputations::ReputationLevel min_rep_for_anonymous ;
RsReputations::ReputationLevel min_rep_for_unknown_signed ;
min_rep_for_anonymous = (grpMeta->mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG )?RsReputations::REPUTATION_REMOTELY_POSITIVE: RsReputations::REPUTATION_REMOTELY_NEGATIVE;
min_rep_for_unknown_signed = (grpMeta->mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN)?RsReputations::REPUTATION_REMOTELY_POSITIVE: RsReputations::REPUTATION_REMOTELY_NEGATIVE;
for(std::vector<RsGxsMsgMetaData*>::iterator vit = msgMetas.begin();vit != msgMetas.end(); ++vit)
{
RsGxsMsgMetaData* m = *vit;
// if anti-spam is enabled, do not send messages from authors with bad reputation
RsIdentityDetails details ;
if(!rsIdentity->getIdDetails(m->mAuthorId,details))
@ -4229,21 +4221,14 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_
std::cerr << /* GXSNETDEBUG_PG(item->PeerId(),item->grpId) << */ " not sending grp message ID " << (*vit)->mMsgId << ", because the identity of the author is not accessible (unknown/not cached)" << std::endl;
continue ;
}
if(!(details.mFlags & RS_IDENTITY_FLAGS_PGP_LINKED) && details.mReputation.mOverallReputationLevel < min_rep_for_anonymous)
{
//#ifdef NXS_NET_DEBUG_0
std::cerr << /* GXSNETDEBUG_PG(item->PeerId(),item->grpId) << */ " not sending item ID " << (*vit)->mMsgId << ", because the author is anonymous has reputation level " << details.mReputation.mOverallReputationLevel << std::endl;
//#endif
continue ;
}
if(!(details.mFlags & RS_IDENTITY_FLAGS_PGP_KNOWN) && details.mReputation.mOverallReputationLevel < min_rep_for_unknown_signed)
{
//#ifdef NXS_NET_DEBUG_0
std::cerr << /* GXSNETDEBUG_PG(item->PeerId(),item->grpId) << */ " not sending item ID " << (*vit)->mMsgId << ", because the author is signed by unknown key, and has reputation level " << details.mReputation.mOverallReputationLevel << std::endl;
//#endif
continue ;
}
if(details.mReputation.mOverallReputationLevel < minReputationForForwardingMessages(grpMeta->mSignFlags, details.mFlags))
{
//#ifdef NXS_NET_DEBUG_0
std::cerr << /* GXSNETDEBUG_PG(item->PeerId(),item->grpId) << */ " not sending item ID " << (*vit)->mMsgId << ", because the author is flags " << std::hex << details.mFlags << std::dec << " and reputation level " << details.mReputation.mOverallReputationLevel << std::endl;
//#endif
continue ;
}
// Check publish TS
if(item->createdSinceTS > (*vit)->mPublishTs)

View file

@ -34,6 +34,8 @@
#include <map>
#include "services/p3service.h"
#include "retroshare/rsreputations.h"
#include "retroshare/rsidentity.h"
#include "rsgds.h"
/*!
@ -159,6 +161,50 @@ public:
* \return
*/
virtual bool stampMsgServerUpdateTS(const RsGxsGroupId& gid) =0;
/*!
* \brief minReputationForForwardingMessages
* Encodes the policy for sending/requesting messages depending on anti-spam settings.
*
* \param group_sign_flags Sign flags from the group meta data
* \param identity_flags Flags of the identity
* \return
*/
static RsReputations::ReputationLevel minReputationForRequestingMessages(uint32_t /* group_sign_flags */, uint32_t /* identity_flags */)
{
// We always request messages, except if the author identity is locally banned.
return RsReputations::REPUTATION_REMOTELY_NEGATIVE;
}
static RsReputations::ReputationLevel minReputationForForwardingMessages(uint32_t group_sign_flags, uint32_t identity_flags)
{
// If anti-spam is enabled, do not send messages from authors with bad reputation. The policy is to only forward messages if the reputation of the author is at least
// equal to the minimal reputation in the table below (R=remotely, L=locally, P=positive, N=negative) :
//
// | Anonymous Signed Signed+Known
// -----------+-----------------------------------------------------
// NONE | RN RN RN
// GPG_AUTHED | RP RN RN
// GPG_KNOWN | RP RP RN
//
if(identity_flags & RS_IDENTITY_FLAGS_PGP_KNOWN)
return RsReputations::REPUTATION_REMOTELY_NEGATIVE;
else if(identity_flags & RS_IDENTITY_FLAGS_PGP_LINKED)
{
if(group_sign_flags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN)
return RsReputations::REPUTATION_REMOTELY_POSITIVE;
else
return RsReputations::REPUTATION_REMOTELY_NEGATIVE;
}
else
{
if( (group_sign_flags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN) || (group_sign_flags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG))
return RsReputations::REPUTATION_REMOTELY_POSITIVE;
else
return RsReputations::REPUTATION_REMOTELY_NEGATIVE;
}
}
};
#endif // RSGNP_H

View file

@ -61,37 +61,36 @@ std::ostream &operator<<(std::ostream &out, const RsGxsForumMsg &msg);
class RsGxsForums: public RsGxsIfaceHelper
{
public:
public:
RsGxsForums(RsGxsIface *gxs)
:RsGxsIfaceHelper(gxs) { return; }
virtual ~RsGxsForums() { return; }
:RsGxsIfaceHelper(gxs) { return; }
virtual ~RsGxsForums() { return; }
/* Specific Service Data */
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsForumGroup> &groups) = 0;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//Not currently used
//virtual bool getRelatedMessages(const uint32_t &token, std::vector<RsGxsForumMsg> &msgs) = 0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
//////////////////////////////////////////////////////////////////////////////
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) = 0;
//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
//virtual bool setMessageStatus(const std::string &msgId, const uint32_t status, const uint32_t statusMask);
//virtual bool setGroupSubscribeFlags(const std::string &groupId, uint32_t subscribeFlags, uint32_t subscribeMask);
//virtual bool groupRestoreKeys(const std::string &groupId);
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
//virtual bool groupRestoreKeys(const std::string &groupId);
//virtual bool groupShareKeys(const std::string &groupId, std::list<std::string>& peers);
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
/*!
virtual bool createGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool createMsg(uint32_t &token, RsGxsForumMsg &msg) = 0;
/*!
* To update forum group with new information
* @param token the token used to check completion status of update
* @param group group to be updated, groupId element must be set or will be rejected
* @return false groupId not set, true if set and accepted (still check token for completion)
*/
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
virtual bool updateGroup(uint32_t &token, RsGxsForumGroup &group) = 0;
};

View file

@ -27,6 +27,7 @@
#ifndef RSGXSIFACE_H_
#define RSGXSIFACE_H_
#include "retroshare/rsreputations.h"
#include "retroshare/rsgxsservice.h"
#include "gxs/rsgxsdata.h"
#include "retroshare/rsgxsifacetypes.h"
@ -181,6 +182,8 @@ public:
virtual uint32_t getDefaultSyncPeriod() = 0;
virtual uint32_t getSyncPeriod(const RsGxsGroupId& grpId) = 0;
virtual void setSyncPeriod(const RsGxsGroupId& grpId,uint32_t age_in_secs) = 0;
virtual RsReputations::ReputationLevel minReputationForForwardingMessages(uint32_t group_sign_flags,uint32_t identity_flags)=0;
};

View file

@ -27,6 +27,7 @@
*/
#include "retroshare/rsgxsiface.h"
#include "retroshare/rsreputations.h"
#include "rsgxsflags.h"
/*!
@ -236,6 +237,10 @@ public:
mGxs->setSyncPeriod(grpId,age_in_secs);
}
RsReputations::ReputationLevel minReputationForForwardingMessages(uint32_t group_sign_flags,uint32_t identity_flags)
{
return mGxs->minReputationForForwardingMessages(group_sign_flags,identity_flags);
}
private:
RsGxsIface* mGxs;