From 1f672773ba418ef56ac283f95e69001e77acedfe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sat, 14 Dec 2019 11:34:34 -0500
Subject: [PATCH] proxy server: respect value priority for push notifications

---
 src/dht_proxy_server.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp
index 8ec8df66..00123093 100644
--- a/src/dht_proxy_server.cpp
+++ b/src/dht_proxy_server.cpp
@@ -706,7 +706,10 @@ DhtProxyServer::subscribe(restinio::request_handle_t request,
                     }
                     json["exp"] = ss.str();
                 }
-                sendPushNotification(pushToken, std::move(json), isAndroid, !expired);
+                auto maxPrio = 1000u;
+                for (const auto& v : values)
+                    maxPrio = std::min(maxPrio, v->priority);
+                sendPushNotification(pushToken, std::move(json), isAndroid, !expired and maxPrio == 0);
                 return true;
             }
         );
-- 
GitLab