Permalink
Browse files

Implement GoogleWebhookController

  • Loading branch information...
lorisleiva committed Oct 2, 2018
1 parent 0f853f7 commit 5a42e4ede72efb7ec809af0628ef845f394ac8e0
Showing with 25 additions and 2 deletions.
  1. +22 −0 app/Http/Controllers/GoogleWebhookController.php
  2. +1 −1 app/Http/Middleware/VerifyCsrfToken.php
  3. +2 −1 routes/web.php
@@ -0,0 +1,22 @@
<?php
namespace App\Http\Controllers;
use App\Synchronization;
use Illuminate\Http\Request;
class GoogleWebhookController extends Controller
{
public function __invoke(Request $request)
{
if ($request->header('x-goog-resource-state') !== 'exists') {
return;
}
Synchronization::query()
->where('id', $request->header('x-goog-channel-id'))
->where('resource_id', $request->header('x-goog-resource-id'))
->firstOrFail()
->ping();
}
}
@@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
//
'google/webhook',
];
}
View
@@ -17,10 +17,11 @@
Auth::routes();
// Managing Google accounts.
// Managing Google accounts and webhooks.
Route::name('google.index')->get('google', 'GoogleAccountController@index');
Route::name('google.store')->get('google/oauth', 'GoogleAccountController@store');
Route::name('google.destroy')->delete('google/{googleAccount}', 'GoogleAccountController@destroy');
Route::name('google.webhook')->post('google/webhook', 'GoogleWebhookController');
// Viewing events.
Route::name('event.index')->get('event', 'EventController@index');

0 comments on commit 5a42e4e

Please sign in to comment.