Skip to content

Commit d8b2bd9

Browse files
committed
fix: view namespace for package
1 parent 32fb02e commit d8b2bd9

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

config/telegram-git-notifier.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969

7070
/** Set the path to the view file */
7171
'view' => [
72+
'namespace' => env('TGN_VIEW_NAMESPACE', 'telegram-git-notifier').'::',
73+
7274
'default' => env(
7375
'TGN_VIEW_DEFAULT',
7476
base_path('resources/views/vendor/telegram-git-notifier')

phpstan-baseline.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
parameters:
2+
excludePaths:
3+
- src/Http/Actions/WebhookAction.php

routes/bot.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use CSlant\LaravelTelegramGitNotifier\Http\Actions\IndexAction;
34
use CSlant\LaravelTelegramGitNotifier\Http\Actions\WebhookAction;
45
use Illuminate\Support\Facades\Route;
56

@@ -15,8 +16,10 @@
1516
*/
1617

1718
Route::prefix('telegram-git-notifier')->group(function () {
19+
Route::any('/', [IndexAction::class, 'index'])->name('telegram-git-notifier.index');
20+
1821
Route::prefix('webhook')->group(function () {
19-
Route::get('/set', [WebhookAction::class, 'set'])->name('webhook.set');
20-
Route::get('/delete', [WebhookAction::class, 'delete'])->name('webhook.delete');
22+
Route::get('/set', [WebhookAction::class, 'set'])->name('telegram-git-notifier.webhook.set');
23+
Route::get('/delete', [WebhookAction::class, 'delete'])->name('telegram-git-notifier.webhook.delete');
2124
});
2225
});

src/Http/Actions/IndexAction.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ public function __construct()
3636
}
3737

3838
/**
39-
* Handle telegram git notifier app
39+
* Handle telegram git notifier app.
4040
*
4141
* @return void
42+
*
4243
* @throws InvalidViewTemplateException
4344
* @throws MessageIsEmptyException
4445
* @throws SendNotificationException
4546
*/
46-
public function __invoke(): void
47+
public function index(): void
4748
{
4849
$sendNotification = new NotificationService(
4950
$this->notifier,

src/Services/NotificationService.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public function __construct(
3232
}
3333

3434
/**
35-
* Handle to send notification from webhook event to telegram
35+
* Handle to send notification from webhook event to telegram.
3636
*
3737
* @return void
38+
*
3839
* @throws InvalidViewTemplateException
3940
* @throws SendNotificationException
4041
* @throws MessageIsEmptyException
@@ -49,8 +50,8 @@ public function handle(): void
4950

5051
/**
5152
* @param string $event
52-
*
5353
* @return void
54+
*
5455
* @throws InvalidViewTemplateException
5556
* @throws SendNotificationException
5657
* @throws MessageIsEmptyException
@@ -81,19 +82,19 @@ private function sendNotification(string $event): void
8182
}
8283

8384
/**
84-
* Validate access event
85+
* Validate access event.
8586
*
8687
* @param string $event
87-
*
8888
* @return bool
89+
*
8990
* @throws InvalidViewTemplateException|MessageIsEmptyException
9091
*/
9192
private function validateAccessEvent(string $event): bool
9293
{
9394
$payload = $this->notifier->setPayload($this->request, $event);
9495
$validator = new Validator($this->setting, $this->notifier->event);
9596

96-
if (empty($payload)
97+
if (empty($payload) || !is_object($payload)
9798
|| !$validator->isAccessEvent(
9899
$this->notifier->event->platform,
99100
$event,

0 commit comments

Comments
 (0)