mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added: Handling requests to add and remove contact
This commit is contained in:
parent
4a99000f16
commit
76dd7fe47f
@ -138,6 +138,9 @@ IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIden
|
||||
addResourceHandler("own_ids", this, &IdentityHandler::handleOwnIdsRequest);
|
||||
addResourceHandler("notown_ids", this, &IdentityHandler::handleNotOwnIdsRequest);
|
||||
|
||||
addResourceHandler("add_contact", this, &IdentityHandler::handleAddContact);
|
||||
addResourceHandler("remove_contact", this, &IdentityHandler::handleRemoveContact);
|
||||
|
||||
addResourceHandler("create_identity", this, &IdentityHandler::handleCreateIdentity);
|
||||
addResourceHandler("delete_identity", this, &IdentityHandler::handleDeleteIdentity);
|
||||
}
|
||||
@ -314,6 +317,36 @@ void IdentityHandler::handleOwnIdsRequest(Request & /*req*/, Response &resp)
|
||||
else resp.setFail();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleAddContact(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), true);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
void IdentityHandler::handleRemoveContact(Request& req, Response& resp)
|
||||
{
|
||||
std::string gxs_id;
|
||||
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
|
||||
|
||||
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), false);
|
||||
|
||||
{
|
||||
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
|
||||
mStateTokenServer->replaceToken(mStateToken);
|
||||
}
|
||||
|
||||
resp.setOk();
|
||||
}
|
||||
|
||||
ResponseTask* IdentityHandler::handleOwn(Request & /* req */, Response &resp)
|
||||
{
|
||||
StateToken state;
|
||||
|
@ -26,6 +26,9 @@ private:
|
||||
void handleNotOwnIdsRequest(Request& req, Response& resp);
|
||||
void handleOwnIdsRequest(Request& req, Response& resp);
|
||||
|
||||
void handleAddContact(Request& req, Response& resp);
|
||||
void handleRemoveContact(Request& req, Response& resp);
|
||||
|
||||
ResponseTask *handleOwn(Request& req, Response& resp);
|
||||
ResponseTask *handleCreateIdentity(Request& req, Response& resp);
|
||||
ResponseTask *handleDeleteIdentity(Request& req, Response& resp);
|
||||
|
Loading…
Reference in New Issue
Block a user