File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CSlant \LaravelTelegramGitNotifier \Commands ;
4+
5+ use CSlant \LaravelTelegramGitNotifier \Services \WebhookService ;
6+ use CSlant \TelegramGitNotifier \Exceptions \WebhookException ;
7+ use Illuminate \Console \Command ;
8+ use Illuminate \Support \Facades \Log ;
9+
10+ class SetWebhook extends Command
11+ {
12+ /**
13+ * The name and signature of the console command.
14+ *
15+ * @var string
16+ */
17+ protected $ signature = 'tg-notifier:webhook:set ' ;
18+
19+ /**
20+ * The console command description.
21+ *
22+ * @var string
23+ */
24+ protected $ description = 'Set webhook ' ;
25+
26+ protected WebhookService $ webhookService ;
27+
28+ public function __construct (WebhookService $ webhookService )
29+ {
30+ parent ::__construct ();
31+ $ this ->webhookService = $ webhookService ;
32+ }
33+
34+ /**
35+ * Execute the console command.
36+ *
37+ * @return void
38+ */
39+ public function handle (): void
40+ {
41+ try {
42+ $ log = $ this ->webhookService ->handle ();
43+
44+ $ this ->info ($ log );
45+ } catch (WebhookException $ e ) {
46+ $ this ->error ($ e ->getMessage ());
47+ }
48+ }
49+ }
Original file line number Diff line number Diff line change 33namespace CSlant \LaravelTelegramGitNotifier \Providers ;
44
55use CSlant \LaravelTelegramGitNotifier \Commands \ChangeOwnerConfigJson ;
6+ use CSlant \LaravelTelegramGitNotifier \Commands \SetWebhook ;
67use Illuminate \Support \ServiceProvider ;
78
89class TelegramGitNotifierServiceProvider extends ServiceProvider
@@ -59,6 +60,7 @@ protected function registerCommands(): void
5960 {
6061 $ this ->commands ([
6162 ChangeOwnerConfigJson::class,
63+ SetWebhook::class,
6264 ]);
6365 }
6466
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace CSlant \LaravelTelegramGitNotifier \Services ;
4+
5+ use CSlant \LaravelTelegramGitNotifier \Http \Actions \WebhookAction ;
6+ use CSlant \TelegramGitNotifier \Exceptions \WebhookException ;
7+
8+ class WebhookService
9+ {
10+ protected WebhookAction $ webhookAction ;
11+
12+ public function __construct (WebhookAction $ webhookAction ) {
13+ $ this ->webhookAction = $ webhookAction ;
14+ }
15+
16+
17+ /**
18+ * @throws WebhookException
19+ */
20+ public function handle (): string
21+ {
22+ return $ this ->webhookAction ->set ();
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments