Added: Handling requests to delete identity

This commit is contained in:
Konrad 2017-04-14 17:41:35 +02:00
parent 98e1a6d74c
commit 93aeae0f59
2 changed files with 39 additions and 1 deletions

View File

@ -95,6 +95,37 @@ protected:
}
};
class DeleteIdentityTask : public GxsResponseTask
{
public:
DeleteIdentityTask(RsIdentity* idservice) :
GxsResponseTask(idservice, idservice->getTokenService()),
mToken(0),
mRsIdentity(idservice)
{}
protected:
virtual void gxsDoWork(Request &req, Response &resp)
{
RsGxsIdGroup group;
std::string gxs_id;
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
group.mMeta.mGroupId = RsGxsGroupId(gxs_id);
mRsIdentity->deleteIdentity(mToken, group);
addWaitingToken(mToken);
done();
return;
}
private:
uint32_t mToken;
RsIdentity* mRsIdentity;
RsGxsId mId;
};
IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIdentity *identity):
mStateTokenServer(sts), mNotify(notify), mRsIdentity(identity),
mMtx("IdentityHandler Mtx"), mStateToken(sts->getNewToken())
@ -108,6 +139,7 @@ IdentityHandler::IdentityHandler(StateTokenServer *sts, RsNotify *notify, RsIden
addResourceHandler("notown_ids", this, &IdentityHandler::handleNotOwnIdsRequest);
addResourceHandler("create_identity", this, &IdentityHandler::handleCreateIdentity);
addResourceHandler("delete_identity", this, &IdentityHandler::handleDeleteIdentity);
}
IdentityHandler::~IdentityHandler()
@ -302,4 +334,9 @@ ResponseTask* IdentityHandler::handleCreateIdentity(Request & /* req */, Respons
return new CreateIdentityTask(mRsIdentity);
}
ResponseTask* IdentityHandler::handleDeleteIdentity(Request& req, Response& resp)
{
return new DeleteIdentityTask(mRsIdentity);
}
} // namespace resource_api

View File

@ -28,6 +28,7 @@ private:
ResponseTask *handleOwn(Request& req, Response& resp);
ResponseTask *handleCreateIdentity(Request& req, Response& resp);
ResponseTask *handleDeleteIdentity(Request& req, Response& resp);
StateTokenServer* mStateTokenServer;
RsNotify* mNotify;