From 120ca9d0783d3dbbd8a7491b8fed3254a880c71f Mon Sep 17 00:00:00 2001 From: Konrad Date: Tue, 18 Apr 2017 22:58:15 +0200 Subject: [PATCH] Added: Handling requests to set opinion about identity --- libresapi/src/api/IdentityHandler.cpp | 15 +++++++++++++++ libresapi/src/api/IdentityHandler.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/libresapi/src/api/IdentityHandler.cpp b/libresapi/src/api/IdentityHandler.cpp index 097a04ef7..1b298467d 100644 --- a/libresapi/src/api/IdentityHandler.cpp +++ b/libresapi/src/api/IdentityHandler.cpp @@ -146,6 +146,8 @@ IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIden addResourceHandler("delete_identity", this, &IdentityHandler::handleDeleteIdentity); addResourceHandler("get_identity_details", this, &IdentityHandler::handleGetIdentityDetails); + + addResourceHandler("set_ban_node", this, &IdentityHandler::handleSetBanNode); } IdentityHandler::~IdentityHandler() @@ -472,6 +474,19 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp) resp.setOk(); } +void IdentityHandler::handleSetBanNode(Request& req, Response& resp) +{ + std::string pgp_id; + req.mStream << makeKeyValueReference("pgp_id", pgp_id); + RsPgpId pgpId(pgp_id); + + bool banned_node; + req.mStream << makeKeyValueReference("banned_node", banned_node); + rsReputations->banNode(pgpId, banned_node); + + resp.setOk(); +} + ResponseTask* IdentityHandler::handleOwn(Request & /* req */, Response &resp) { StateToken state; diff --git a/libresapi/src/api/IdentityHandler.h b/libresapi/src/api/IdentityHandler.h index 0780585e8..3824d483d 100644 --- a/libresapi/src/api/IdentityHandler.h +++ b/libresapi/src/api/IdentityHandler.h @@ -31,6 +31,8 @@ private: void handleGetIdentityDetails(Request& req, Response& resp); + void handleSetBanNode(Request& req, Response& resp); + ResponseTask *handleOwn(Request& req, Response& resp); ResponseTask *handleCreateIdentity(Request& req, Response& resp); ResponseTask *handleDeleteIdentity(Request& req, Response& resp);