Skip to content
Snippets Groups Projects
Commit 39bb5203 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

proxy server: don't send refresh notification for non-push operations

parent 18e53b9e
No related branches found
No related tags found
No related merge requests found
...@@ -415,7 +415,7 @@ DhtProxyServer::loadState(Is& is, size_t size) { ...@@ -415,7 +415,7 @@ DhtProxyServer::loadState(Is& is, size_t size) {
json["s"] = sessionCtx->sessionId; json["s"] = sessionCtx->sessionId;
} }
if (expired and values.size() < 2){ if (expired and values.size() < 2){
std::stringstream ss; std::ostringstream ss;
for(size_t i = 0; i < values.size(); ++i){ for(size_t i = 0; i < values.size(); ++i){
if(i != 0) ss << ","; if(i != 0) ss << ",";
ss << values[i]->id; ss << values[i]->id;
...@@ -892,7 +892,7 @@ DhtProxyServer::subscribe(restinio::request_handle_t request, ...@@ -892,7 +892,7 @@ DhtProxyServer::subscribe(restinio::request_handle_t request,
json["s"] = sessionCtx->sessionId; json["s"] = sessionCtx->sessionId;
} }
if (expired and values.size() < 2){ if (expired and values.size() < 2){
std::stringstream ss; std::ostringstream ss;
for(size_t i = 0; i < values.size(); ++i) { for(size_t i = 0; i < values.size(); ++i) {
if(i != 0) ss << ","; if(i != 0) ss << ",";
ss << values[i]->id; ss << values[i]->id;
...@@ -967,7 +967,7 @@ DhtProxyServer::handleNotifyPushListenExpire(const asio::error_code &ec, const s ...@@ -967,7 +967,7 @@ DhtProxyServer::handleNotifyPushListenExpire(const asio::error_code &ec, const s
logger_->e("[proxy:server] [subscribe] error sending put refresh: %s", ec.message().c_str()); logger_->e("[proxy:server] [subscribe] error sending put refresh: %s", ec.message().c_str());
} }
if (logger_) if (logger_)
logger_->d("[proxy:server] [subscribe] sending put refresh to %s token", pushToken.c_str()); logger_->d("[proxy:server] [subscribe] sending refresh to %s token", pushToken.c_str());
sendPushNotification(pushToken, jsonProvider(), type, false, topic); sendPushNotification(pushToken, jsonProvider(), type, false, topic);
} }
...@@ -1217,6 +1217,7 @@ DhtProxyServer::put(restinio::request_handle_t request, ...@@ -1217,6 +1217,7 @@ DhtProxyServer::put(restinio::request_handle_t request,
#ifdef OPENDHT_PUSH_NOTIFICATIONS #ifdef OPENDHT_PUSH_NOTIFICATIONS
// notify put permanent expiration // notify put permanent expiration
if (pput.sessionCtx) {
auto jsonProvider = [infoHash, clientId, vid, sessionCtx = pput.sessionCtx](){ auto jsonProvider = [infoHash, clientId, vid, sessionCtx = pput.sessionCtx](){
Json::Value json; Json::Value json;
json["timeout"] = infoHash.toString(); json["timeout"] = infoHash.toString();
...@@ -1234,6 +1235,7 @@ DhtProxyServer::put(restinio::request_handle_t request, ...@@ -1234,6 +1235,7 @@ DhtProxyServer::put(restinio::request_handle_t request,
pput.expireNotifyTimer->async_wait(std::bind( pput.expireNotifyTimer->async_wait(std::bind(
&DhtProxyServer::handleNotifyPushListenExpire, this, &DhtProxyServer::handleNotifyPushListenExpire, this,
std::placeholders::_1, pushToken, std::move(jsonProvider), pput.type, pput.topic)); std::placeholders::_1, pushToken, std::move(jsonProvider), pput.type, pput.topic));
}
#endif #endif
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment