Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25d98a4ee3 |
@@ -23,4 +23,8 @@ return [
|
|||||||
// 'did_change_renewal_status' => \App\Jobs\AppstoreNotifications\HandleDidChangeRenewalStatus::class,
|
// 'did_change_renewal_status' => \App\Jobs\AppstoreNotifications\HandleDidChangeRenewalStatus::class,
|
||||||
],
|
],
|
||||||
'proxy_host' => env('APPLE_PROXY_HOST'),
|
'proxy_host' => env('APPLE_PROXY_HOST'),
|
||||||
|
/*
|
||||||
|
* Seconds to wait for the proxy_host before giving up (the forward never blocks our own processing).
|
||||||
|
*/
|
||||||
|
'proxy_timeout' => env('APPLE_PROXY_TIMEOUT', 5),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class ProxyHelper {
|
|||||||
|
|
||||||
private $addQuery;
|
private $addQuery;
|
||||||
|
|
||||||
|
//Timeout in seconds (connect and total), none if empty
|
||||||
|
private $timeout;
|
||||||
|
|
||||||
//If needed add cookies support with:
|
//If needed add cookies support with:
|
||||||
// - PendingRequest->withCookies
|
// - PendingRequest->withCookies
|
||||||
// - Request->hasCookie
|
// - Request->hasCookie
|
||||||
@@ -53,6 +56,8 @@ class ProxyHelper {
|
|||||||
|
|
||||||
public function preserveQuery($preserve){ $this->addQuery = $preserve; return $this; }
|
public function preserveQuery($preserve){ $this->addQuery = $preserve; return $this; }
|
||||||
|
|
||||||
|
public function withTimeout($seconds){ $this->timeout = $seconds; return $this; }
|
||||||
|
|
||||||
public function getResponse($url){
|
public function getResponse($url){
|
||||||
|
|
||||||
$info = $this->getRequestInfo();
|
$info = $this->getRequestInfo();
|
||||||
@@ -60,6 +65,8 @@ class ProxyHelper {
|
|||||||
$http = $this->createHttp($info['type']);
|
$http = $this->createHttp($info['type']);
|
||||||
$http = $this->setAuth($http, $info['token']);
|
$http = $this->setAuth($http, $info['token']);
|
||||||
$http = $this->setHeaders($http);
|
$http = $this->setHeaders($http);
|
||||||
|
if($this->timeout)
|
||||||
|
$http = $http->timeout((int)$this->timeout)->withOptions(['connect_timeout' => (int)$this->timeout]);
|
||||||
|
|
||||||
if($this->addQuery && $info['query'])
|
if($this->addQuery && $info['query'])
|
||||||
$url = $url.'?'.http_build_query($info['query']);
|
$url = $url.'?'.http_build_query($info['query']);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Appvise\AppStoreNotifications;
|
|||||||
|
|
||||||
use Appvise\AppStoreNotifications\ProxyHelperFacade;
|
use Appvise\AppStoreNotifications\ProxyHelperFacade;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
use Appvise\AppStoreNotifications\Model\NotificationType;
|
use Appvise\AppStoreNotifications\Model\NotificationType;
|
||||||
use Appvise\AppStoreNotifications\Model\AppleNotification;
|
use Appvise\AppStoreNotifications\Model\AppleNotification;
|
||||||
use Appvise\AppStoreNotifications\Exceptions\WebhookFailed;
|
use Appvise\AppStoreNotifications\Exceptions\WebhookFailed;
|
||||||
@@ -15,7 +16,14 @@ class WebhooksController
|
|||||||
{
|
{
|
||||||
$proxy_host = config('appstore-server-notifications.proxy_host');
|
$proxy_host = config('appstore-server-notifications.proxy_host');
|
||||||
if (!empty($proxy_host)) {
|
if (!empty($proxy_host)) {
|
||||||
ProxyHelperFacade::CreateProxy($request)->toUrl($proxy_host);
|
// The forward must never stop our own processing: short timeout, errors only logged.
|
||||||
|
try {
|
||||||
|
ProxyHelperFacade::CreateProxy($request)
|
||||||
|
->withTimeout(config('appstore-server-notifications.proxy_timeout', 5))
|
||||||
|
->toUrl($proxy_host);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::warning("Apple notification forward to {$proxy_host} failed: " . $e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$jobConfigKey = NotificationType::{$request->input('notification_type')}();
|
$jobConfigKey = NotificationType::{$request->input('notification_type')}();
|
||||||
|
|||||||
Reference in New Issue
Block a user