Added: Handling requests to set opinion about identity

This commit is contained in:
Konrad 2017-04-18 23:00:59 +02:00
parent 120ca9d078
commit b43bedf669
2 changed files with 32 additions and 0 deletions

View File

@ -148,6 +148,7 @@ IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIden
addResourceHandler("get_identity_details", this, &IdentityHandler::handleGetIdentityDetails); addResourceHandler("get_identity_details", this, &IdentityHandler::handleGetIdentityDetails);
addResourceHandler("set_ban_node", this, &IdentityHandler::handleSetBanNode); addResourceHandler("set_ban_node", this, &IdentityHandler::handleSetBanNode);
addResourceHandler("set_opinion", this, &IdentityHandler::handleSetOpinion);
} }
IdentityHandler::~IdentityHandler() IdentityHandler::~IdentityHandler()
@ -487,6 +488,36 @@ void IdentityHandler::handleSetBanNode(Request& req, Response& resp)
resp.setOk(); resp.setOk();
} }
void IdentityHandler::handleSetOpinion(Request& req, Response& resp)
{
std::string gxs_id;
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
RsGxsId gxsId(gxs_id);
int own_opinion;
req.mStream << makeKeyValueReference("own_opinion", own_opinion);
RsReputations::Opinion opinion;
switch(own_opinion)
{
case 0:
opinion = RsReputations::OPINION_NEGATIVE;
break;
case 1: opinion =
RsReputations::OPINION_NEUTRAL;
break;
case 2:
opinion = RsReputations::OPINION_POSITIVE;
break;
default:
resp.setFail();
return;
}
rsReputations->setOwnOpinion(gxsId, opinion);
resp.setOk();
}
ResponseTask* IdentityHandler::handleOwn(Request & /* req */, Response &resp) ResponseTask* IdentityHandler::handleOwn(Request & /* req */, Response &resp)
{ {
StateToken state; StateToken state;

View File

@ -32,6 +32,7 @@ private:
void handleGetIdentityDetails(Request& req, Response& resp); void handleGetIdentityDetails(Request& req, Response& resp);
void handleSetBanNode(Request& req, Response& resp); void handleSetBanNode(Request& req, Response& resp);
void handleSetOpinion(Request& req, Response& resp);
ResponseTask *handleOwn(Request& req, Response& resp); ResponseTask *handleOwn(Request& req, Response& resp);
ResponseTask *handleCreateIdentity(Request& req, Response& resp); ResponseTask *handleCreateIdentity(Request& req, Response& resp);