Modify UnifiedPush post request to be AND_3 compliant

This commit is contained in:
Lucas Fryzek authored and Adrien Béraud committed 2025-11-30 10:54:18 -05:00
1 parent e028c1be8c
commit 55ac11bf5c
1 file changed
+12 -1
+12 -1
View File
@@ -1142,7 +1142,18 @@ DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& jso
request->set_header_field(restinio::http_field_t::host, type == PushType::UnifiedPush ? tokenUrl.host.c_str() : pushServer_.c_str());
request->set_header_field(restinio::http_field_t::user_agent, "RESTinio client");
request->set_header_field(restinio::http_field_t::accept, "*/*");
request->set_header_field(restinio::http_field_t::content_type, "application/json");
if (type == PushType::UnifiedPush) {
// Unified Push with AND_3 expects encrypted WebPush requests. We can make
// our request look like a real WebPush request by adding Content-Encoding
// and TTL headers to our request and just sending the plain json data.
// This should work since the content of push message is already e2ee.
// See https://codeberg.org/UnifiedPush/wishlist/issues/22
request->set_header_field(restinio::http_field_t::content_encoding, "aes128gcm");
request->set_header_field(restinio::http_field_t::ttl, "86400");
request->set_header_field(restinio::http_field_t::urgency, highPriority ? "high" : "normal");
} else {
request->set_header_field(restinio::http_field_t::content_type, "application/json");
}
if (type == PushType::UnifiedPush) {
Json::Value notification(Json::objectValue);