Skip to content

Commit

Permalink
fix(push): Make testing the push server easier
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 10, 2024
1 parent 2881c0c commit 34eb497
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/Push.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ protected function sendNotificationsToProxies(): void {
return;
}

$subscriptionAwareServer = rtrim($this->config->getAppValue(Application::APP_ID, 'subscription_aware_server', 'https://push-notifications.nextcloud.com'), '/');
if ($subscriptionAwareServer === 'https://push-notifications.nextcloud.com') {
$subscriptionKey = $this->config->getAppValue('support', 'subscription_key');
} else {
$subscriptionKey = $this->config->getSystemValueString('instanceid');
}

$client = $this->clientService->newClient();
foreach ($pushNotifications as $proxyServer => $notifications) {
try {
Expand All @@ -431,11 +438,8 @@ protected function sendNotificationsToProxies(): void {
],
];

if ($proxyServer === 'https://push-notifications.nextcloud.com') {
$subscriptionKey = $this->config->getAppValue('support', 'subscription_key');
if ($subscriptionKey) {
$requestData['headers']['X-Nextcloud-Subscription-Key'] = $subscriptionKey;
}
if ($subscriptionKey !== '' && $proxyServer === $subscriptionAwareServer) {
$requestData['headers']['X-Nextcloud-Subscription-Key'] = $subscriptionKey;
}

$response = $client->post($proxyServer . '/notifications', $requestData);
Expand Down

0 comments on commit 34eb497

Please sign in to comment.