Fixed: Responds sends now correct time difference

This commit is contained in:
Konrad 2017-04-21 23:44:00 +02:00
parent c9f618ddf6
commit 8c0b7ce776
2 changed files with 5 additions and 3 deletions

View File

@ -413,7 +413,7 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp)
resp.mDataStream << makeKeyValue("pgp_name", pgp_name); resp.mDataStream << makeKeyValue("pgp_name", pgp_name);
time_t now = time(NULL); time_t now = time(NULL);
resp.mDataStream << makeKeyValue("last_usage", std::to_string(now - data.mLastUsageTS)); resp.mDataStream << makeKeyValue("last_usage", difftime(now, data.mLastUsageTS));
bool isAnonymous = false; bool isAnonymous = false;
if(!data.mPgpKnown) if(!data.mPgpKnown)
@ -468,7 +468,7 @@ void IdentityHandler::handleGetIdentityDetails(Request& req, Response& resp)
for(std::map<RsIdentityUsage,time_t>::const_iterator it(details.mUseCases.begin()); it != details.mUseCases.end(); ++it) for(std::map<RsIdentityUsage,time_t>::const_iterator it(details.mUseCases.begin()); it != details.mUseCases.end(); ++it)
{ {
usagesStream.getStreamToMember() << makeKeyValue("usage_time", std::to_string(now - it->second)); usagesStream.getStreamToMember() << makeKeyValue("usage_time", difftime(now, data.mLastUsageTS));
usagesStream.getStreamToMember() << makeKeyValue("usage_service", (int)(it->first.mServiceId)); usagesStream.getStreamToMember() << makeKeyValue("usage_service", (int)(it->first.mServiceId));
usagesStream.getStreamToMember() << makeKeyValue("usage_case", (int)(it->first.mUsageCode)); usagesStream.getStreamToMember() << makeKeyValue("usage_case", (int)(it->first.mUsageCode));
} }

View File

@ -7,6 +7,7 @@
#include <retroshare/rsiface.h> #include <retroshare/rsiface.h>
#include <algorithm> #include <algorithm>
#include <time.h>
#include "Operators.h" #include "Operators.h"
#include "ApiTypes.h" #include "ApiTypes.h"
@ -745,11 +746,12 @@ void PeersHandler::handleGetNodeOptions(Request& req, Response& resp)
return; return;
} }
time_t now = time(NULL);
resp.mDataStream << makeKeyValue("peer_id", detail.id.toStdString()); resp.mDataStream << makeKeyValue("peer_id", detail.id.toStdString());
resp.mDataStream << makeKeyValue("name", detail.name); resp.mDataStream << makeKeyValue("name", detail.name);
resp.mDataStream << makeKeyValue("location", detail.location); resp.mDataStream << makeKeyValue("location", detail.location);
resp.mDataStream << makeKeyValue("pgp_id", detail.gpg_id.toStdString()); resp.mDataStream << makeKeyValue("pgp_id", detail.gpg_id.toStdString());
resp.mDataStream << makeKeyValue("last_contact", detail.lastConnect); resp.mDataStream << makeKeyValue("last_contact", difftime(now, detail.lastConnect));
std::string status_message = mRsMsgs->getCustomStateString(detail.id); std::string status_message = mRsMsgs->getCustomStateString(detail.id);
resp.mDataStream << makeKeyValueReference("status_message", status_message); resp.mDataStream << makeKeyValueReference("status_message", status_message);