From 54bf0054a0db34bb72112b167e4c076c826b60ca Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Oct 2022 16:38:30 +0200 Subject: [PATCH] Send the subscription key to the Community push proxy Signed-off-by: Joas Schilling --- lib/Push.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Push.php b/lib/Push.php index 3fd323f94..94f76484d 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -379,11 +379,20 @@ protected function sendNotificationsToProxies(): void { $client = $this->clientService->newClient(); foreach ($pushNotifications as $proxyServer => $notifications) { try { - $response = $client->post($proxyServer . '/notifications', [ + $requestData = [ 'body' => [ 'notifications' => $notifications, ], - ]); + ]; + + if ($proxyServer === 'https://push-notifications.nextcloud.com') { + $subscriptionKey = $this->config->getAppValue('support', 'subscription_key'); + if ($subscriptionKey) { + $requestData['headers']['X-Nextcloud-Subscription-Key'] = $subscriptionKey; + } + } + + $response = $client->post($proxyServer . '/notifications', $requestData); $status = $response->getStatusCode(); $body = $response->getBody(); $bodyData = json_decode($body, true);