Skip to content

Commit

Permalink
Merge pull request #93 from tanhongit/main
Browse files Browse the repository at this point in the history
Gitlab notification
  • Loading branch information
tanhongit authored Aug 26, 2023
2 parents a814d63 + a1d9fd2 commit 1cc5950
Show file tree
Hide file tree
Showing 52 changed files with 398 additions and 118 deletions.
13 changes: 13 additions & 0 deletions common/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,16 @@ function convert_event_name(string $event): string
return singularity(get_event_name($event));
}
}

if (!function_exists('convert_action_name')) {
/**
* Convert action name
*
* @param string $action
* @return string
*/
function convert_action_name(string $action): string
{
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $action));
}
}
4 changes: 2 additions & 2 deletions config/jsons/gitlab-event.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"note": {
"issue": true,
"merge_request": true,
"commit": false,
"snippet": false
"snippet": false,
"commit": false
},
"merge_request": {
"open": true,
Expand Down
6 changes: 3 additions & 3 deletions resources/events/github/issue_comment/created.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

$event = 'comment';

$message = "⚠️ <b>New Issue Comment</b> 💬 to 🦑<a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->comment->user->html_url}\">@{$payload->comment->user->login}</a>\n\n";
$message = "💬 <b>New Issue Comment</b> ⚠️ to 🦑<a href=\"{$payload->issue->html_url}\">{$payload->repository->full_name}#{$payload->issue->number}</a> by <a href=\"{$payload->comment->user->html_url}\">@{$payload->comment->user->login}</a>\n\n";

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issue_comment/deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issue_comment/edited.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/closed.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
2 changes: 1 addition & 1 deletion resources/events/github/issues/deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

echo $message;
2 changes: 1 addition & 1 deletion resources/events/github/issues/edited.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

if (isset($payload->changes->title)) {
$message .= "📖 <b>Title</b> has been changed\n";
Expand Down
4 changes: 2 additions & 2 deletions resources/events/github/issues/locked.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/opened.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/pinned.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/reopened.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/unlocked.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/issues/unpinned.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->issue->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/pull_request/closed.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

$message .= "🌳 {$payload->pull_request->head->ref} -> {$payload->pull_request->base->ref} 🎯 \n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/github/pull_request/opened.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

$message .= "🌳 {$payload->pull_request->head->ref} -> {$payload->pull_request->base->ref} 🎯 \n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if (isset($payload->pull_request->requested_reviewers) && count($payload->pull_request->requested_reviewers) > 0) {
$reviewers = [];
foreach ($payload->pull_request->requested_reviewers as $reviewer) {
$reviewers[] = $reviewer->login;
$reviewers[] = "<b>{$reviewer->login}</b>";
}

$textReviewers .= "👥 Reviewers: " . implode(', ', $reviewers) . "\n";
Expand Down
4 changes: 2 additions & 2 deletions resources/events/github/pull_request/reopened.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

$message .= "🌳 {$payload->pull_request->head->ref} -> {$payload->pull_request->base->ref} 🎯 \n";

$message .= require __DIR__ . '/../../../shared/partials/github/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/github/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../../shared/partials/github/_body.php';
$message .= require __DIR__ . '/../../shared/partials/github/_body.php';

echo $message;
22 changes: 22 additions & 0 deletions resources/events/gitlab/feature_flag/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* @var $payload mixed
*/

if ($payload->object_attributes->active) {
$active = "Enabled";
$icon = "🚩";
} else {
$active = "Disabled";
$icon = "🏴";
}

$flagUrl = $payload->project->web_url . "/-/feature_flags/" . $payload->object_attributes->id;

$message = "{$icon} <b>Feature Flag {$active}</b> - 🦊<a href=\"{$flagUrl}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->name}</a> by <a href=\"{$payload->user_url}\">{$payload->user->name}</a>\n\n";

$message .= "{$icon} Name: <b>{$payload->object_attributes->name}</b> \n\n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/gitlab/issue/close.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->object_attributes->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_body.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/gitlab/issue/open.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->object_attributes->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_body.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/gitlab/issue/reopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->object_attributes->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_body.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
4 changes: 2 additions & 2 deletions resources/events/gitlab/issue/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

$message .= "📢 <b>{$payload->object_attributes->title}</b>\n";

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_assignees.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/../../../shared/partials/gitlab/_body.php';
$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
18 changes: 18 additions & 0 deletions resources/events/gitlab/merge_request/approved.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @var $payload mixed
*/

$message = "✅ <b>Merge Request Approved</b> to 🦊<a href=\"{$payload->object_attributes->url}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->iid}</a> by <b>{$payload->user->name}</b>\n\n";

$message .= "🛠 <b>{$payload->object_attributes->title}</b> \n\n";

$message .= "🌳 {$payload->object_attributes->source_branch} -> {$payload->object_attributes->target_branch} 🎯 \n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
18 changes: 18 additions & 0 deletions resources/events/gitlab/merge_request/close.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @var $payload mixed
*/

$message = "❌ <b>Close Merge Request</b> - 🦊<a href=\"{$payload->object_attributes->url}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->iid}</a> by <b>{$payload->user->name}</b>\n\n";

$message .= "🛠 <b>{$payload->object_attributes->title}</b> \n\n";

$message .= "🌳 {$payload->object_attributes->source_branch} -> {$payload->object_attributes->target_branch} 🎯 \n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
18 changes: 18 additions & 0 deletions resources/events/gitlab/merge_request/merge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @var $payload mixed
*/

$message = "✅🎉 <b>Merge Request Merged</b> to 🦊<a href=\"{$payload->object_attributes->url}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->iid}</a> by <b>{$payload->user->name}</b>\n\n";

$message .= "🛠 <b>{$payload->object_attributes->title}</b> \n\n";

$message .= "🌳 {$payload->object_attributes->source_branch} -> {$payload->object_attributes->target_branch} 🎯 \n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
18 changes: 18 additions & 0 deletions resources/events/gitlab/merge_request/open.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @var $payload mixed
*/

$message = "👷‍♂️🛠️ <b>Merge Request Opened</b> to 🦊<a href=\"{$payload->object_attributes->url}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->iid}</a> by <b>{$payload->user->name}</b>\n\n";

$message .= "🛠 <b>{$payload->object_attributes->title}</b> \n\n";

$message .= "🌳 {$payload->object_attributes->source_branch} -> {$payload->object_attributes->target_branch} 🎯 \n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
16 changes: 16 additions & 0 deletions resources/events/gitlab/merge_request/partials/_reviewers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* @var $payload mixed
*/

$textReviewers = '';
if (isset($payload->reviewers) && count($payload->reviewers) > 0) {
$reviewers = [];
foreach ($payload->reviewers as $reviewer) {
$reviewers[] = "<b>{$reviewer->name}</b>";
}

$textReviewers .= "👥 Reviewers: " . implode(', ', $reviewers) . "\n";
}

return $textReviewers;
18 changes: 18 additions & 0 deletions resources/events/gitlab/merge_request/reopen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* @var $payload mixed
*/

$message = "👷‍♂️🛠️ <b>Merge Request Reopened</b> to 🦊<a href=\"{$payload->object_attributes->url}\">{$payload->project->path_with_namespace}#{$payload->object_attributes->iid}</a> by <b>{$payload->user->name}</b>\n\n";

$message .= "🛠 <b>{$payload->object_attributes->title}</b> \n\n";

$message .= "🌳 {$payload->object_attributes->source_branch} -> {$payload->object_attributes->target_branch} 🎯 \n";

$message .= require __DIR__ . '/../../shared/partials/gitlab/_assignees.php';

$message .= require __DIR__ . '/partials/_reviewers.php';

$message .= require __DIR__ . '/../../shared/partials/gitlab/_body.php';

echo $message;
Loading

0 comments on commit 1cc5950

Please sign in to comment.