Page MenuHomePhorge

D4821.1775334799.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D4821.1775334799.diff

diff --git a/src/app/CompanionApp.php b/src/app/CompanionApp.php
--- a/src/app/CompanionApp.php
+++ b/src/app/CompanionApp.php
@@ -2,8 +2,9 @@
namespace App;
-use Illuminate\Database\Eloquent\Model;
use App\Traits\UuidStrKeyTrait;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Facades\Http;
/**
* The eloquent definition of a CompanionApp.
@@ -35,31 +36,18 @@
private static function pushFirebaseNotification($deviceIds, $data): bool
{
\Log::debug("sending notification to " . var_export($deviceIds, true));
- $apiKey = \config('firebase.api_key');
- $client = new \GuzzleHttp\Client(
- [
- 'verify' => \config('firebase.api_verify_tls')
- ]
- );
- $response = $client->request(
- 'POST',
- \config('firebase.api_url'),
- [
- 'headers' => [
- 'Authorization' => "key={$apiKey}",
- ],
- 'json' => [
- 'registration_ids' => $deviceIds,
- 'data' => $data
- ]
- ]
- );
+ $apiKey = \config('firebase.api_key');
+ $apiUrl = \config('firebase.api_url');
+ $verify = \config('firebase.api_verify_tls');
+ Http::withOptions(['verify' => $verify])
+ ->withHeaders(['Authorization' => "key={$apiKey}"])
+ ->timeout(5)
+ ->connectTimeout(5)
+ ->post($apiUrl, ['registration_ids' => $deviceIds, 'data' => $data])
+ ->throwUnlessStatus(200);
- if ($response->getStatusCode() != 200) {
- throw new \Exception('FCM Send Error: ' . $response->getStatusCode());
- }
return true;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 8:33 PM (1 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18831085
Default Alt Text
D4821.1775334799.diff (1 KB)

Event Timeline