Skip to content
Snippets Groups Projects
Commit aa93db4f authored by Adrien Béraud's avatar Adrien Béraud Committed by Sébastien Blin
Browse files

proxy server: move json to sendPushNotification

parent 683570a3
Branches
Tags
No related merge requests found
...@@ -253,7 +253,7 @@ private: ...@@ -253,7 +253,7 @@ private:
* @param key of the device * @param key of the device
* @param json, the content to send * @param json, the content to send
*/ */
void sendPushNotification(const std::string& key, const Json::Value& json, bool isAndroid) const; void sendPushNotification(const std::string& key, Json::Value&& json, bool isAndroid) const;
/** /**
* Remove a push listener between a client and a hash * Remove a push listener between a client and a hash
......
...@@ -478,7 +478,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session) ...@@ -478,7 +478,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
Json::Value json; Json::Value json;
json["key"] = infoHash.toString(); json["key"] = infoHash.toString();
json["to"] = clientId; json["to"] = clientId;
sendPushNotification(pushToken, json, isAndroid); sendPushNotification(pushToken, std::move(json), isAndroid);
return true; return true;
} }
); );
...@@ -493,7 +493,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session) ...@@ -493,7 +493,7 @@ DhtProxyServer::subscribe(const std::shared_ptr<restbed::Session>& session)
Json::Value json; Json::Value json;
json["timeout"] = infoHash.toString(); json["timeout"] = infoHash.toString();
json["to"] = clientId; json["to"] = clientId;
sendPushNotification(pushToken, json, isAndroid); sendPushNotification(pushToken, std::move(json), isAndroid);
} }
); );
} }
...@@ -571,7 +571,7 @@ DhtProxyServer::cancelPushListen(const std::string& pushToken, const dht::InfoHa ...@@ -571,7 +571,7 @@ DhtProxyServer::cancelPushListen(const std::string& pushToken, const dht::InfoHa
} }
void void
DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value& json, bool isAndroid) const DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& json, bool isAndroid) const
{ {
if (pushServer_.empty()) if (pushServer_.empty())
return; return;
...@@ -583,9 +583,9 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value ...@@ -583,9 +583,9 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value
Json::Value notification(Json::objectValue); Json::Value notification(Json::objectValue);
Json::Value tokens(Json::arrayValue); Json::Value tokens(Json::arrayValue);
tokens[0] = token; tokens[0] = token;
notification["tokens"] = tokens; notification["tokens"] = std::move(tokens);
notification["platform"] = isAndroid ? 2 : 1; notification["platform"] = isAndroid ? 2 : 1;
notification["data"] = json; notification["data"] = std::move(json);
notification["priority"] = "high"; notification["priority"] = "high";
notification["time_to_live"] = 600; notification["time_to_live"] = 600;
...@@ -593,7 +593,7 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value ...@@ -593,7 +593,7 @@ DhtProxyServer::sendPushNotification(const std::string& token, const Json::Value
notifications[0] = notification; notifications[0] = notification;
Json::Value content; Json::Value content;
content["notifications"] = notifications; content["notifications"] = std::move(notifications);
Json::StreamWriterBuilder wbuilder; Json::StreamWriterBuilder wbuilder;
wbuilder["commentStyle"] = "None"; wbuilder["commentStyle"] = "None";
...@@ -694,7 +694,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session) ...@@ -694,7 +694,7 @@ DhtProxyServer::put(const std::shared_ptr<restbed::Session>& session)
json["timeout"] = infoHash.toString(); json["timeout"] = infoHash.toString();
json["to"] = clientId; json["to"] = clientId;
json["vid"] = std::to_string(vid); json["vid"] = std::to_string(vid);
sendPushNotification(pushToken, json, isAndroid); sendPushNotification(pushToken, std::move(json), isAndroid);
}); });
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment