@@ -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 ()
0 commit comments