Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117918416
D4821.1775418714.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D4821.1775418714.diff
View Options
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');
+ $response = 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
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 7:51 PM (13 h, 2 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832848
Default Alt Text
D4821.1775418714.diff (1 KB)
Attached To
Mode
D4821: Use Laravel HTTP client in CompanionApp
Attached
Detach File
Event Timeline