2015-10-04 23:18:31 -04:00
|
|
|
/*
|
|
|
|
* libretroshare/src/services: rsreputation.h
|
|
|
|
*
|
|
|
|
* Services for RetroShare.
|
|
|
|
*
|
|
|
|
* Copyright 2015 by Cyril Soler
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "csoler@users.sourceforge.net".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "retroshare/rsids.h"
|
|
|
|
#include "retroshare/rsgxsifacetypes.h"
|
|
|
|
|
|
|
|
class RsReputations
|
|
|
|
{
|
|
|
|
public:
|
2016-03-29 15:22:14 -04:00
|
|
|
static const float REPUTATION_THRESHOLD_ANTI_SPAM;
|
|
|
|
static const float REPUTATION_THRESHOLD_DEFAULT;
|
2015-10-25 23:45:33 -04:00
|
|
|
|
2015-10-04 23:18:31 -04:00
|
|
|
// This is the interface file for the reputation system
|
|
|
|
//
|
2016-12-23 11:52:02 -05:00
|
|
|
enum Opinion { OPINION_NEGATIVE = 0, OPINION_NEUTRAL = 1, OPINION_POSITIVE = 2 } ;
|
|
|
|
|
|
|
|
enum ReputationLevel { REPUTATION_LOCALLY_NEGATIVE = 0x00, // local opinion is positive
|
|
|
|
REPUTATION_REMOTELY_NEGATIVE = 0x01, // local opinion is neutral and friends are positive in average
|
|
|
|
REPUTATION_NEUTRAL = 0x02, // no reputation information ;
|
|
|
|
REPUTATION_REMOTELY_POSITIVE = 0x03, // local opinion is neutral and friends are negative in average
|
2016-12-27 11:17:23 -05:00
|
|
|
REPUTATION_LOCALLY_POSITIVE = 0x04, // local opinion is negative
|
|
|
|
REPUTATION_UNKNOWN = 0x05 // missing info
|
2016-12-23 11:52:02 -05:00
|
|
|
};
|
2015-10-04 23:18:31 -04:00
|
|
|
|
|
|
|
struct ReputationInfo
|
|
|
|
{
|
2017-02-05 18:11:26 -05:00
|
|
|
ReputationInfo() : mOwnOpinion(OPINION_NEUTRAL),mFriendsPositiveVotes(0),mFriendsNegativeVotes(0), mFriendAverageScore(REPUTATION_THRESHOLD_DEFAULT),mOverallReputationLevel(REPUTATION_NEUTRAL){}
|
2016-01-01 22:36:07 -05:00
|
|
|
|
2015-10-04 23:18:31 -04:00
|
|
|
RsReputations::Opinion mOwnOpinion ;
|
2016-12-23 11:52:02 -05:00
|
|
|
|
|
|
|
uint32_t mFriendsPositiveVotes ;
|
|
|
|
uint32_t mFriendsNegativeVotes ;
|
|
|
|
|
|
|
|
float mFriendAverageScore ;
|
|
|
|
|
|
|
|
RsReputations::ReputationLevel mOverallReputationLevel; // this should help clients in taking decisions
|
2015-10-04 23:18:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
virtual bool setOwnOpinion(const RsGxsId& key_id, const Opinion& op) =0;
|
2017-01-13 12:31:50 -05:00
|
|
|
virtual bool getOwnOpinion(const RsGxsId& key_id, Opinion& op) =0;
|
2017-01-10 17:05:00 -05:00
|
|
|
virtual bool getReputationInfo(const RsGxsId& id, const RsPgpId &ownerNode, ReputationInfo& info,bool stamp=true) =0;
|
2017-01-09 17:47:51 -05:00
|
|
|
virtual ReputationLevel overallReputationLevel(const RsGxsId& id)=0;
|
2016-07-25 15:45:49 -04:00
|
|
|
|
|
|
|
// parameters
|
|
|
|
|
|
|
|
virtual void setNodeAutoPositiveOpinionForContacts(bool b) =0;
|
|
|
|
virtual bool nodeAutoPositiveOpinionForContacts() =0;
|
|
|
|
|
2016-12-28 12:58:49 -05:00
|
|
|
virtual uint32_t thresholdForRemotelyNegativeReputation()=0;
|
|
|
|
virtual uint32_t thresholdForRemotelyPositiveReputation()=0;
|
|
|
|
virtual void setThresholdForRemotelyNegativeReputation(uint32_t thresh)=0;
|
|
|
|
virtual void setThresholdForRemotelyPositiveReputation(uint32_t thresh)=0;
|
|
|
|
|
2017-01-12 14:39:49 -05:00
|
|
|
virtual void setRememberDeletedNodesThreshold(uint32_t days) =0;
|
|
|
|
virtual uint32_t rememberDeletedNodesThreshold() =0;
|
|
|
|
|
2016-12-28 12:58:49 -05:00
|
|
|
// This one is a proxy designed to allow fast checking of a GXS id.
|
|
|
|
// it basically returns true if assessment is not ASSESSMENT_OK
|
2015-10-06 23:56:39 -04:00
|
|
|
|
2016-08-04 05:43:35 -04:00
|
|
|
virtual bool isIdentityBanned(const RsGxsId& id) =0;
|
|
|
|
|
|
|
|
virtual bool isNodeBanned(const RsPgpId& id) =0;
|
|
|
|
virtual void banNode(const RsPgpId& id,bool b) =0;
|
2015-10-04 23:18:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// To access reputations from anywhere
|
|
|
|
//
|
|
|
|
extern RsReputations *rsReputations ;
|