-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06767eb
commit 5a5734a
Showing
9 changed files
with
154 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
; This file is for unifying the coding style for different editors and IDEs. | ||
; More information at http://editorconfig.org | ||
|
||
# EditorConfig is awesome: http://EditorConfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[{Makefile,*.mak}] | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[{Makefile,*.mak,*.sh,*.yml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
layout php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/tests export-ignore | ||
* text=auto eol=lf whitespace=tab-in-indent,blank-at-eol,tabwidth=4 | ||
makefile text whitespace=-tab-in-indent,blank-at-eol,tabwidth=4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
illuminate-version: | ||
- 9 | ||
- 10 | ||
php-version: | ||
- 8.0 | ||
- 8.1 | ||
- 8.2 | ||
exclude: | ||
- illuminate-version: 10 | ||
php-version: 8.0 | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php-version }} | ||
tools: composer:v2 | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer require \ | ||
--no-ansi \ | ||
--no-interaction \ | ||
--no-progress \ | ||
--no-scripts \ | ||
--prefer-dist \ | ||
illuminate/support:^${{ matrix.illuminate-version }} | ||
- name: Lint Code | ||
run: vendor/bin/tlint | ||
|
||
- name: Run tests | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
/.envrc | ||
/.idea/ | ||
/.phpunit.result.cache | ||
/composer.lock | ||
/vendor | ||
build | ||
composer.lock | ||
composer.phar | ||
.idea/ | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Ringierimu\ServiceBusNotificationsChannel; | ||
|
||
use Aws\Sqs\SqsClient; | ||
use Illuminate\Notifications\Notification; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Facades\Log; | ||
|
||
class ServiceBusSQSChannel | ||
{ | ||
protected SqsClient $sqs; | ||
|
||
public function __construct(array $config = []) | ||
{ | ||
$this->config = $config ?: config('services.service_bus'); | ||
|
||
$this->sqs = new SqsClient([ | ||
'region' => Arr::get($this->config, 'sqs.region'), | ||
'version' => 'latest', | ||
'credentials' => [ | ||
'key' => Arr::get($this->config, 'sqs.key'), | ||
'secret' => Arr::get($this->config, 'sqs.secret'), | ||
], | ||
]); | ||
} | ||
|
||
public function send($notifiable, Notification $notification) | ||
{ | ||
/** @var ServiceBusEvent $event */ | ||
$event = $notification->toServiceBus($notifiable); | ||
$eventType = $event->getEventType(); | ||
$params = $event->getParams(); | ||
$dontReport = Arr::get($this->config, 'dont_report', []); | ||
|
||
if (Arr::get($this->config, 'enabled') == false) { | ||
if (!in_array($eventType, $dontReport)) { | ||
Log::debug( | ||
"$eventType service bus notification [disabled]", | ||
[ | ||
'event' => $eventType, | ||
'params' => $params, | ||
'tags' => [ | ||
'service-bus', | ||
], | ||
] | ||
); | ||
} | ||
|
||
return; | ||
} | ||
|
||
$message = $notification | ||
->toServiceBus($notifiable) | ||
->getParams(); | ||
|
||
$response = $this->sqs->sendMessage([ | ||
'QueueUrl' => Arr::get($this->config, 'sqs.queue_url'), | ||
'MessageBody' => json_encode($message), | ||
'MessageGroupId' => $message['from'], | ||
]); | ||
|
||
$event = $message['events'][0]; | ||
|
||
Log::info("{$event} sent to bus queue", [ | ||
'message_id' => $response->get('MessageId'), | ||
'message' => $message, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"preset": "laravel", | ||
"disabled": [ | ||
"SpaceAfterSoleNotOperator", | ||
"NoParensEmptyInstantiations", | ||
"OneLineBetweenClassVisibilityChanges", | ||
"ModelMethodOrder", | ||
"ConcatenationNoSpacing" | ||
] | ||
} |