Skip to content

Commit

Permalink
Merge pull request #20 from tanhongit/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tanhongit authored Nov 12, 2023
2 parents d0c5ecb + 13fd3a2 commit 15763b1
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 11 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/routes',
__DIR__ . '/resources',
])
->name('*.php')
->ignoreDotFiles(true)
Expand Down
10 changes: 5 additions & 5 deletions config/telegram-git-notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
return [
'defaults' => [
'paths' => [
'view' => env(
'views' => env(
'TGN_DEFAULT_PATH_VIEW',
base_path('resources/views/vendor/telegram-git-notifier')
base_path('resources/views/vendor/tg-notifier')
),
],
],
Expand All @@ -14,7 +14,7 @@
'name' => env('TGN_APP_NAME', 'Laravel Telegram Git Notifier'),

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

Expand Down Expand Up @@ -69,11 +69,11 @@

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

'default' => env(
'TGN_VIEW_DEFAULT',
base_path('resources/views/vendor/telegram-git-notifier')
base_path('resources/views/vendor/tg-notifier')
),

'event' => [
Expand Down
2 changes: 1 addition & 1 deletion lang/en/app.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

return [

'by' => 'by',
];
8 changes: 8 additions & 0 deletions lang/en/events/github/issues.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
'issue_title' => '📢',
'closed' => [
'title' => '🚫 <b>Issue Closed </b> to 🦑 :issue by :user',
],
];
7 changes: 7 additions & 0 deletions lang/en/events/shared/github.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'_body' => [
'title' => '📖 <b>Content:</b>',
],
];
12 changes: 10 additions & 2 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
parameters:
excludePaths:
- src/Http/Actions/WebhookAction.php
ignoreErrors:
- message: '#Parameter \#2 \$namespace of method Illuminate\\Support\\ServiceProvider\:\:loadViewsFrom\(\) expects string, mixed given\.#'
path: src/Providers/TelegramGitNotifierServiceProvider.php


- message: '#Parameter \#1 \$token of method CSlant\\TelegramGitNotifier\\Webhook\:\:setToken\(\) expects string, mixed given\.#'
path: src/Http/Actions/WebhookAction.php

- message: '#Parameter \#1 \$url of method CSlant\\TelegramGitNotifier\\Webhook\:\:setUrl\(\) expects string, mixed given\.#'
path: src/Http/Actions/WebhookAction.php
20 changes: 20 additions & 0 deletions resources/views/events/github/issues/closed.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* @var $payload mixed
* @var $event string
*/
$issue = $payload->issue;
?>

{!! __('tg-notifier::events/github/issues.closed.title', [
'issue' => "<a href='$issue->html_url'>{$payload->repository->full_name}#$issue->number</a>",
'user' => "<a href='{$issue->user->html_url}'>@{$issue->user->login}</a>"
]
) !!}

{!! __('tg-notifier::events/github/issues.issue_title') !!} <b><?= $issue->title; ?></b>

@include('tg-notifier::events.shared.partials.github._assignees', compact('payload', 'event'))

@include('tg-notifier::events.shared.partials.github._body', compact('payload', 'event'))
16 changes: 16 additions & 0 deletions resources/views/events/shared/partials/github/_assignees.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
* @var $event string
*/
if (isset($event) && isset($payload) && !empty($payload->{$event}->assignees)) {
$assigneeText = "🙋 Assignee: ";
$assigneeArray = [];
foreach ($payload->{$event}->assignees as $assignee) {
$assigneeArray[] = "<a href=\"{$assignee->html_url}\">@{$assignee->login}</a> ";
}
$assigneeText .= implode(', ', $assigneeArray)."\n";
}
?>
{!! $assigneeText ?? '' !!}
16 changes: 16 additions & 0 deletions resources/views/events/shared/partials/github/_body.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
* @var $event string
*/
if (isset($event) && isset($payload) && !empty($payload->{$event}->body)) {
$body = $payload->{$event}->body;
if (strlen($body) > 50) {
$body = substr($body, 0, 50).'...';
}
$html = __('tg-notifier::events/shared/github._body.title', ['body' => $body])."\n{$body}";
}
?>
{!! $html ?? '' !!}
6 changes: 3 additions & 3 deletions src/Providers/TelegramGitNotifierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ public function boot(): void

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

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

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

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

Expand Down

0 comments on commit 15763b1

Please sign in to comment.