Skip to content

Commit

Permalink
chore: refactor and fix coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
digitlimit committed Nov 7, 2023
1 parent 86b4cd5 commit 854b5b8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/Events/NoPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace Digitlimit\Githook\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

Expand Down
7 changes: 0 additions & 7 deletions src/Events/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

namespace Digitlimit\Githook\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

Expand All @@ -16,15 +13,11 @@ class Webhook

/**
* The type of event
*
* @var
*/
public $type;

/**
* The event payload
*
* @var
*/
public $payload;

Expand Down
4 changes: 1 addition & 3 deletions src/GithookServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Digitlimit\Githook;

use Illuminate\Support\ServiceProvider;
use Digitlimit\Githook\Http\Controllers\GithookController;
use Digitlimit\Githook\Providers\EventServiceProvider;
use Illuminate\Support\ServiceProvider;

class GithookServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -38,8 +38,6 @@ public function register()

/**
* Console-specific booting.
*
* @return void
*/
protected function bootForConsole(): void
{
Expand Down
12 changes: 6 additions & 6 deletions src/Http/Controllers/GithookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace Digitlimit\Githook\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Digitlimit\Githook\Events\NoPayload;
use Digitlimit\Githook\Events\Webhook;
use Illuminate\Http\Request;

class GithookController extends Controller
{
/**
* Perform the git hook.
*
* @param Request $request
* @return void
*/
public function __invoke(Request $request)
{
if (!$request->has('payload')) {
if (! $request->has('payload')) {
NoPayload::dispatch($request->all());
info('No payload received');

return;
}

Expand All @@ -41,9 +41,9 @@ protected function authCheck()
$github_hash = request()->header('X-Hub-Signature');
$secret = config('githook.secret');
$payload = request()->getContent();
$local_hash = 'sha1=' . hash_hmac('sha1', $payload, $secret, false);

$local_hash = 'sha1='.hash_hmac('sha1', $payload, $secret, false);

return hash_equals($github_hash, $local_hash);
}
}
}
2 changes: 0 additions & 2 deletions src/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Digitlimit\Githook\Providers;

use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use Digitlimit\Githook\Events\NoPayload;

class EventServiceProvider extends ServiceProvider
{
Expand Down

0 comments on commit 854b5b8

Please sign in to comment.