mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Remove cruft from PeersHandler::handleGetInactiveUsers
Move documentaion to header
This commit is contained in:
parent
341c94ee6c
commit
62eefa4fed
@ -779,29 +779,14 @@ void PeersHandler::handleRemoveNode(Request &req, Response &resp)
|
|||||||
else resp.setFail("handleRemoveNode Invalid peer_id");
|
else resp.setFail("handleRemoveNode Invalid peer_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Retrieve inactive user list before specific UNIX time
|
|
||||||
*
|
|
||||||
* \param [in] req request from user, datatime in UNIX timestamp.
|
|
||||||
* \param [in] resp response to request
|
|
||||||
* \return a pgp_id list.
|
|
||||||
*
|
|
||||||
* \details Combine this with handleRemoveNode,
|
|
||||||
* batch remove inactive users are possible and convenient.
|
|
||||||
*/
|
|
||||||
void PeersHandler::handleGetInactiveUsers(Request &req, Response &resp)
|
void PeersHandler::handleGetInactiveUsers(Request &req, Response &resp)
|
||||||
{
|
{
|
||||||
std::string datetime;
|
std::string datetime;
|
||||||
req.mStream << makeKeyValueReference("datetime", datetime);
|
req.mStream << makeKeyValueReference("datetime", datetime);
|
||||||
|
|
||||||
uint32_t before = strtoul(datetime.c_str(), NULL, 10);
|
uint32_t before;
|
||||||
|
if(datetime.empty()) before = time(NULL);
|
||||||
if(datetime.empty())
|
else before = strtoul(datetime.c_str(), NULL, 10);
|
||||||
{
|
|
||||||
std::cerr << "PeersHandler:datetime is empty" << std::endl;
|
|
||||||
before = time(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// list all peers
|
// list all peers
|
||||||
std::list<RsPeerId> peers;
|
std::list<RsPeerId> peers;
|
||||||
@ -811,7 +796,8 @@ void PeersHandler::handleGetInactiveUsers(Request &req, Response &resp)
|
|||||||
std::map<RsPgpId, uint32_t> mapRsPgpId;
|
std::map<RsPgpId, uint32_t> mapRsPgpId;
|
||||||
|
|
||||||
// get all peers' infomations
|
// get all peers' infomations
|
||||||
for(std::list<RsPeerId>::iterator lt = peers.begin(); lt != peers.end(); ++lt)
|
for( std::list<RsPeerId>::iterator lt = peers.begin(); lt != peers.end();
|
||||||
|
++lt )
|
||||||
{
|
{
|
||||||
RsPeerDetails details;
|
RsPeerDetails details;
|
||||||
mRsPeers->getPeerDetails(*lt, details);
|
mRsPeers->getPeerDetails(*lt, details);
|
||||||
@ -823,9 +809,9 @@ void PeersHandler::handleGetInactiveUsers(Request &req, Response &resp)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mapRsPgpId.insert(std::make_pair(details.gpg_id, details.lastConnect));
|
mapRsPgpId.insert(
|
||||||
|
std::make_pair(details.gpg_id, details.lastConnect) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark response as list, in case it is empty
|
// mark response as list, in case it is empty
|
||||||
@ -834,27 +820,18 @@ void PeersHandler::handleGetInactiveUsers(Request &req, Response &resp)
|
|||||||
std::map<RsPgpId, uint32_t>::iterator lit;
|
std::map<RsPgpId, uint32_t>::iterator lit;
|
||||||
for( lit = mapRsPgpId.begin(); lit != mapRsPgpId.end(); ++lit)
|
for( lit = mapRsPgpId.begin(); lit != mapRsPgpId.end(); ++lit)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (lit->second < before)
|
if (lit->second < before)
|
||||||
{
|
{
|
||||||
|
resp.mDataStream.getStreamToMember()
|
||||||
std::cerr << "YES Adding OLD: " << mRsPeers->getGPGName(lit->first);
|
<< makeKeyValue("pgp_id", lit->first.toStdString())
|
||||||
std::cerr << "last_contact: " << lit->second <<std::endl;
|
<< makeKeyValue("name", mRsPeers->getGPGName(lit->first))
|
||||||
|
<< makeKeyValue("last_contact", lit->second);
|
||||||
StreamBase& itemStream = resp.mDataStream.getStreamToMember();
|
|
||||||
itemStream << makeKeyValue("pgp_id", lit->first.toStdString());
|
|
||||||
itemStream << makeKeyValue("name", mRsPeers->getGPGName(lit->first));
|
|
||||||
itemStream << makeKeyValue("last_contact", lit->second);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resp.setOk();
|
resp.setOk();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PeersHandler::handleGetNetworkOptions(Request& /*req*/, Response& resp)
|
void PeersHandler::handleGetNetworkOptions(Request& /*req*/, Response& resp)
|
||||||
{
|
{
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
|
@ -81,7 +81,13 @@ private:
|
|||||||
*/
|
*/
|
||||||
void handleRemoveNode(Request &req, Response &resp);
|
void handleRemoveNode(Request &req, Response &resp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Retrieve inactive user list before specific UNIX time
|
||||||
|
*
|
||||||
|
* \param [in] req request from user, datatime in UNIX timestamp.
|
||||||
|
* \param [in] resp response to request
|
||||||
|
* \return a pgp_id list.
|
||||||
|
*/
|
||||||
void handleGetInactiveUsers(Request &req, Response &resp);
|
void handleGetInactiveUsers(Request &req, Response &resp);
|
||||||
|
|
||||||
/// Helper which ensures proper mutex locking
|
/// Helper which ensures proper mutex locking
|
||||||
|
Loading…
Reference in New Issue
Block a user