Skip to content

Commit 15763b1

Browse files
authored
Merge pull request #20 from tanhongit/develop
Develop
2 parents d0c5ecb + 13fd3a2 commit 15763b1

File tree

10 files changed

+87
-11
lines changed

10 files changed

+87
-11
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
__DIR__ . '/src',
66
__DIR__ . '/tests',
77
__DIR__ . '/routes',
8+
__DIR__ . '/resources',
89
])
910
->name('*.php')
1011
->ignoreDotFiles(true)

config/telegram-git-notifier.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
return [
44
'defaults' => [
55
'paths' => [
6-
'view' => env(
6+
'views' => env(
77
'TGN_DEFAULT_PATH_VIEW',
8-
base_path('resources/views/vendor/telegram-git-notifier')
8+
base_path('resources/views/vendor/tg-notifier')
99
),
1010
],
1111
],
@@ -14,7 +14,7 @@
1414
'name' => env('TGN_APP_NAME', 'Laravel Telegram Git Notifier'),
1515

1616
// Required for the bot to work properly
17-
'url' => env('TGN_APP_URL', 'http://localhost:8000'),
17+
'url' => env('TGN_APP_URL', 'http://localhost:8000/telegram-git-notifier'),
1818
'timezone' => env('TIMEZONE', 'Asia/Ho_Chi_Minh'),
1919
],
2020

@@ -69,11 +69,11 @@
6969

7070
/** Set the path to the view file */
7171
'view' => [
72-
'namespace' => env('TGN_VIEW_NAMESPACE', 'telegram-git-notifier').'::',
72+
'namespace' => env('TGN_VIEW_NAMESPACE', 'tg-notifier'),
7373

7474
'default' => env(
7575
'TGN_VIEW_DEFAULT',
76-
base_path('resources/views/vendor/telegram-git-notifier')
76+
base_path('resources/views/vendor/tg-notifier')
7777
),
7878

7979
'event' => [

lang/en/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
22

33
return [
4-
4+
'by' => 'by',
55
];

lang/en/events/github/issues.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
'issue_title' => '📢',
5+
'closed' => [
6+
'title' => '🚫 <b>Issue Closed </b> to 🦑 :issue by :user',
7+
],
8+
];

lang/en/events/shared/github.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
return [
4+
'_body' => [
5+
'title' => '📖 <b>Content:</b>',
6+
],
7+
];

phpstan-baseline.neon

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
parameters:
2-
excludePaths:
3-
- src/Http/Actions/WebhookAction.php
2+
ignoreErrors:
3+
- message: '#Parameter \#2 \$namespace of method Illuminate\\Support\\ServiceProvider\:\:loadViewsFrom\(\) expects string, mixed given\.#'
4+
path: src/Providers/TelegramGitNotifierServiceProvider.php
5+
6+
7+
- message: '#Parameter \#1 \$token of method CSlant\\TelegramGitNotifier\\Webhook\:\:setToken\(\) expects string, mixed given\.#'
8+
path: src/Http/Actions/WebhookAction.php
9+
10+
- message: '#Parameter \#1 \$url of method CSlant\\TelegramGitNotifier\\Webhook\:\:setUrl\(\) expects string, mixed given\.#'
11+
path: src/Http/Actions/WebhookAction.php
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
/**
3+
* @var $payload mixed
4+
* @var $event string
5+
*/
6+
7+
$issue = $payload->issue;
8+
?>
9+
10+
{!! __('tg-notifier::events/github/issues.closed.title', [
11+
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
12+
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
13+
]
14+
) !!}
15+
16+
{!! __('tg-notifier::events/github/issues.issue_title') !!} <b><?= $issue->title; ?></b>
17+
18+
@include('tg-notifier::events.shared.partials.github._assignees', compact('payload', 'event'))
19+
20+
@include('tg-notifier::events.shared.partials.github._body', compact('payload', 'event'))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* @var $payload mixed
4+
* @var $event string
5+
*/
6+
7+
if (isset($event) && isset($payload) && !empty($payload->{$event}->assignees)) {
8+
$assigneeText = "🙋 Assignee: ";
9+
$assigneeArray = [];
10+
foreach ($payload->{$event}->assignees as $assignee) {
11+
$assigneeArray[] = "<a href=\"{$assignee->html_url}\">@{$assignee->login}</a> ";
12+
}
13+
$assigneeText .= implode(', ', $assigneeArray)."\n";
14+
}
15+
?>
16+
{!! $assigneeText ?? '' !!}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* @var $payload mixed
4+
* @var $event string
5+
*/
6+
7+
if (isset($event) && isset($payload) && !empty($payload->{$event}->body)) {
8+
$body = $payload->{$event}->body;
9+
if (strlen($body) > 50) {
10+
$body = substr($body, 0, 50).'...';
11+
}
12+
13+
$html = __('tg-notifier::events/shared/github._body.title', ['body' => $body])."\n{$body}";
14+
}
15+
?>
16+
{!! $html ?? '' !!}

src/Providers/TelegramGitNotifierServiceProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public function boot(): void
2020

2121
$viewPath = __DIR__.'/../../resources/views';
2222
if (file_exists($viewPath)) {
23-
$this->loadViewsFrom($viewPath, 'telegram-git-notifier');
23+
$this->loadViewsFrom($viewPath, config('telegram-git-notifier.view.namespace'));
2424
}
2525

26-
$this->loadTranslationsFrom(__DIR__.'/../../lang', 'telegram-git-notifier');
26+
$this->loadTranslationsFrom(__DIR__.'/../../lang', 'tg-notifier');
2727

2828
$configPath = __DIR__.'/../../config/telegram-git-notifier.php';
2929
$this->publishes([
@@ -35,7 +35,7 @@ public function boot(): void
3535
], 'views');
3636

3737
$this->publishes([
38-
__DIR__.'/../../lang' => resource_path('lang/vendor/telegram-git-notifier'),
38+
__DIR__.'/../../lang' => resource_path('lang/vendor/tg-notifier'),
3939
], 'lang');
4040
}
4141

0 commit comments

Comments
 (0)