Skip to content

Commit 09342a7

Browse files
fix: change code activity stream cli set webhook
1 parent 9400fca commit 09342a7

File tree

4 files changed

+55
-25
lines changed

4 files changed

+55
-25
lines changed

composer.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,7 @@
5151
},
5252
"scripts": {
5353
"analyse": "vendor/bin/phpstan analyse",
54-
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
55-
"post-install-cmd": [
56-
"bash vendor/cslant/telegram-git-notifier/install.sh"
57-
],
58-
"post-update-cmd": [
59-
"bash vendor/cslant/telegram-git-notifier/install.sh"
60-
]
54+
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
6155
},
6256
"support": {
6357
"issues": "https://github.com/cslant/laravel-telegram-git-notifier/issues"

src/Commands/SetWebhook.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use CSlant\LaravelTelegramGitNotifier\Services\WebhookService;
66
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
77
use Illuminate\Console\Command;
8-
use Illuminate\Support\Facades\Log;
98

109
class SetWebhook extends Command
1110
{
@@ -39,7 +38,7 @@ public function __construct(WebhookService $webhookService)
3938
public function handle(): void
4039
{
4140
try {
42-
$log = $this->webhookService->handle();
41+
$log = $this->webhookService->setWebhook();
4342

4443
$this->info($log);
4544
} catch (WebhookException $e) {

src/Http/Actions/WebhookAction.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
namespace CSlant\LaravelTelegramGitNotifier\Http\Actions;
44

5+
use CSlant\LaravelTelegramGitNotifier\Services\WebhookService;
56
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
6-
use CSlant\TelegramGitNotifier\Webhook;
77

88
class WebhookAction
99
{
10-
protected Webhook $webhook;
10+
protected WebhookService $webhookService;
1111

12-
public function __construct()
12+
public function __construct(WebhookService $webhookService)
1313
{
14-
$this->webhook = new Webhook();
15-
$this->webhook->setToken(config('telegram-git-notifier.bot.token'));
16-
$this->webhook->setUrl(config('telegram-git-notifier.app.url'));
14+
$this->webhookService = $webhookService;
1715
}
1816

1917
/**
@@ -25,7 +23,7 @@ public function __construct()
2523
*/
2624
public function set(): string
2725
{
28-
return $this->webhook->setWebhook();
26+
return $this->webhookService->setWebhook();
2927
}
3028

3129
/**
@@ -37,7 +35,7 @@ public function set(): string
3735
*/
3836
public function delete(): string
3937
{
40-
return $this->webhook->deleteWebHook();
38+
return $this->webhookService->deleteWebHook();
4139
}
4240

4341
/**
@@ -49,7 +47,7 @@ public function delete(): string
4947
*/
5048
public function getUpdates(): string
5149
{
52-
return $this->webhook->getUpdates();
50+
return $this->webhookService->getUpdates();
5351
}
5452

5553
/**
@@ -61,6 +59,6 @@ public function getUpdates(): string
6159
*/
6260
public function getWebHookInfo(): string
6361
{
64-
return $this->webhook->getWebHookInfo();
62+
return $this->webhookService->getWebHookInfo();
6563
}
6664
}

src/Services/WebhookService.php

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,62 @@
22

33
namespace CSlant\LaravelTelegramGitNotifier\Services;
44

5-
use CSlant\LaravelTelegramGitNotifier\Http\Actions\WebhookAction;
65
use CSlant\TelegramGitNotifier\Exceptions\WebhookException;
6+
use CSlant\TelegramGitNotifier\Webhook;
77

88
class WebhookService
99
{
10-
protected WebhookAction $webhookAction;
10+
protected Webhook $webhook;
1111

12-
public function __construct(WebhookAction $webhookAction) {
13-
$this->webhookAction = $webhookAction;
12+
public function __construct(Webhook $webhook)
13+
{
14+
$this->webhook = $webhook;
15+
$this->webhook->setToken(config('telegram-git-notifier.bot.token'));
16+
$this->webhook->setUrl(config('telegram-git-notifier.app.url'));
17+
}
18+
19+
/**
20+
* Set webhook for telegram bot.
21+
*
22+
* @return string
23+
* @throws WebhookException
24+
*/
25+
public function setWebhook(): string
26+
{
27+
return $this->webhook->setWebhook();
28+
}
29+
30+
/**
31+
* Delete webhook for telegram bot.
32+
*
33+
* @return string
34+
* @throws WebhookException
35+
*/
36+
public function deleteWebHook(): string
37+
{
38+
return $this->webhook->deleteWebHook();
1439
}
1540

41+
/**
42+
* Get webhook update.
43+
*
44+
* @return string
45+
* @throws WebhookException
46+
*/
47+
public function getUpdates(): string
48+
{
49+
return $this->webhook->getUpdates();
50+
}
1651

1752
/**
53+
* Get webhook info.
54+
*
55+
* @return string
56+
*
1857
* @throws WebhookException
1958
*/
20-
public function handle(): string
59+
public function getWebHookInfo(): string
2160
{
22-
return $this->webhookAction->set();
61+
return $this->webhook->getWebHookInfo();
2362
}
2463
}

0 commit comments

Comments
 (0)