diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h index 195f8206ee1a403d0ab1449c84ee047f096a5fd0..bcb83405ca3b94e6e6cc2f4432a1b1a0ee4d5b0d 100644 --- a/include/opendht/dht_proxy_server.h +++ b/include/opendht/dht_proxy_server.h @@ -281,7 +281,7 @@ private: * @param key of the device * @param json, the content to send */ - void sendPushNotification(const std::string& key, Json::Value&& json, bool isAndroid); + void sendPushNotification(const std::string& key, Json::Value&& json, bool isAndroid, bool highPriority); /** * Send push notification with an expire timeout. diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp index 07b9f89cce72a918218f6a07d464d8338751dd23..8ec8df66469271a82d5594b6901eb7182540dc11 100644 --- a/src/dht_proxy_server.cpp +++ b/src/dht_proxy_server.cpp @@ -706,7 +706,7 @@ DhtProxyServer::subscribe(restinio::request_handle_t request, } json["exp"] = ss.str(); } - sendPushNotification(pushToken, std::move(json), isAndroid); + sendPushNotification(pushToken, std::move(json), isAndroid, !expired); return true; } ); @@ -802,7 +802,7 @@ DhtProxyServer::handleNotifyPushListenExpire(const asio::error_code &ec, const s } if (logger_) logger_->d("[proxy:server] [subscribe] sending put refresh to %s token", pushToken.c_str()); - sendPushNotification(pushToken, std::move(json), isAndroid); + sendPushNotification(pushToken, std::move(json), isAndroid, false); } void @@ -844,7 +844,7 @@ DhtProxyServer::handleCancelPushListen(const asio::error_code &ec, const std::st } void -DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& json, bool isAndroid) +DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& json, bool isAndroid, bool highPriority) { if (pushServer_.empty()) return; @@ -868,7 +868,7 @@ DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& jso notification["tokens"] = std::move(tokens); notification["platform"] = isAndroid ? 2 : 1; notification["data"] = std::move(json); - notification["priority"] = "high"; + notification["priority"] = highPriority ? "high" : "normal"; notification["time_to_live"] = 600; Json::Value notifications(Json::arrayValue);