Skip to content

Commit 59cc87a

Browse files
committed
🍺
1 parent f91e25d commit 59cc87a

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
composer.lock
2+
vendor
3+
.phpunit.result.cache
4+
.php_cs.cache
5+
.nova/*

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@
2424
"Thoughtco\\StatamicPostmarkSpamcheck\\ServiceProvider"
2525
]
2626
}
27+
},
28+
"require-dev": {
29+
"laravel/pint": "^1.0"
2730
}
2831
}

config/statamic-postmark-spamcheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
'fail_silently' => true,
77

88
'test_mode' => env('STATAMIC_POSTMARK_SPAMCHECK_TEST_MODE', 'off'),
9-
9+
1010
'threshold' => 5,
1111
];

src/Listeners/FormSubmittedListener.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,31 @@ public function handle(FormSubmitted $event)
4242
$content = $form->blueprint()
4343
->fields()->all()
4444
->filter(fn ($field) => $field->type() == 'textarea' || ($field->type() == 'text' && $field->get('input_type', '') != 'email'))
45-
->map(function ($field) use ($apiKey, $submission) {
45+
->map(function ($field) use ($submission) {
4646
return $submission->get($field->handle());
4747
})
4848
->filter()
4949
->join("\n");
50-
50+
5151
if (! $content) {
5252
return;
5353
}
54-
54+
5555
$email = $form->blueprint()
5656
->fields()->all()
5757
->filter(fn ($field) => $field->type() == 'text' && $field->get('input_type', '') != 'email')
58-
->map(function ($field) use ($apiKey, $submission) {
58+
->map(function ($field) use ($submission) {
5959
return $submission->get($field->handle());
6060
})
6161
->filter()
6262
->first() ?? '';
63-
63+
6464
$body = view('statamic-postmark-spamcheck::email', [
6565
'content' => $content,
6666
'date' => now(),
6767
'email' => $email,
6868
])->render();
69-
69+
7070
$response = Http::withHeaders(['apikey' => $apiKey])
7171
->withBody($content, 'text/plain')
7272
->post('https://spamcheck.postmarkapp.com/filter', [
@@ -75,22 +75,22 @@ public function handle(FormSubmitted $event)
7575
]);
7676

7777
$json = $response->json();
78-
78+
7979
// handle postmark error
8080
if (! ($json['success'] ?? false)) {
8181
return;
8282
}
83-
83+
8484
if ($score = Arr::get($json, 'score', false)) {
8585

8686
if ($score >= config('statamic-postmark-spamcheck.threshold')) {
8787
if (config('statamic-postmark-spamcheck.fail_silently')) {
8888
return false;
8989
}
90-
90+
9191
$this->throwFailure();
9292
}
93-
}
93+
}
9494
}
9595

9696
public function throwFailure()

src/ServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ class ServiceProvider extends AddonServiceProvider
1313
public function boot()
1414
{
1515
parent::boot();
16-
16+
1717
$this->loadViewsFrom(__DIR__.'/../resources/views/', 'statamic-postmark-spamcheck');
1818

1919
if ($this->app->runningInConsole()) {
2020
$this->publishes([
2121
__DIR__.'/../config/statamic-postmark-spamcheck.php' => config_path('statamic-postmark-spamcheck.php'),
2222
], 'statamic-postmark-spamcheck');
23-
23+
2424
$this->publishes([
2525
__DIR__.'/../resources/views' => resource_path('views/vendor/statamic-postmark-spamcheck'),
2626
], 'statamic-postmark-spamcheck-views');

0 commit comments

Comments
 (0)