File tree Expand file tree Collapse file tree 8 files changed +32
-41
lines changed Expand file tree Collapse file tree 8 files changed +32
-41
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ abstract class Job
1919 protected $ webhookCall ;
2020
2121 /**
22- * Location of the root
22+ * Location of the root.
2323 *
2424 * @var string
2525 */
@@ -36,17 +36,17 @@ public function __construct(WebhookCall $webhookCall)
3636 }
3737
3838 /**
39- * Fetch Payload
39+ * Fetch Payload.
4040 *
4141 * @return array
4242 */
43- protected function payload () : array
43+ protected function payload (): array
4444 {
4545 return $ this ->webhookCall ->payload ;
4646 }
4747
4848 /**
49- * Get the value from the payload's event data
49+ * Get the value from the payload's event data.
5050 *
5151 * @param string $key
5252 * @return mixed
Original file line number Diff line number Diff line change 22
33namespace BinaryCats \BigBlueButtonWebhooks \Jobs ;
44
5- use BinaryCats \BigBlueButtonWebhooks \Jobs \Job ;
6- use Spatie \WebhookClient \Models \WebhookCall ;
7-
85class MeetingCreatedJob extends Job
96{
107 /**
@@ -14,6 +11,5 @@ class MeetingCreatedJob extends Job
1411 */
1512 public function handle ()
1613 {
17-
1814 }
1915}
Original file line number Diff line number Diff line change 22
33namespace BinaryCats \BigBlueButtonWebhooks ;
44
5- use Illuminate \Http \Request ;
6-
75class Webhook
86{
97 /**
Original file line number Diff line number Diff line change 44
55use Illuminate \Http \Request ;
66use Illuminate \Support \Arr ;
7- use Spatie \WebhookClient \WebhookConfig ;
87use Spatie \WebhookClient \Models \WebhookCall as Model ;
8+ use Spatie \WebhookClient \WebhookConfig ;
99
1010class WebhookCall extends Model
1111{
12- public static function storeWebhook (WebhookConfig $ config , Request $ request ): WebhookCall
12+ public static function storeWebhook (WebhookConfig $ config , Request $ request ): self
1313 {
14- # payload is not proper JSON, rather is it split between three blocks
14+ // payload is not proper JSON, rather is it split between three blocks
1515 $ payload = $ request ->input ();
16- # transform event
17- if ($ event = Arr::get ($ payload , 'event ' , null ) AND is_string ($ event )) {
16+ // transform event
17+ if ($ event = Arr::get ($ payload , 'event ' , null ) and is_string ($ event )) {
1818 $ payload ['event ' ] = json_decode ($ event , true );
1919 }
20- # create
20+ // create
2121 return self ::create ([
2222 'name ' => $ config ->name ,
2323 'payload ' => $ payload ,
Original file line number Diff line number Diff line change 22
33namespace BinaryCats \BigBlueButtonWebhooks ;
44
5- use Illuminate \Http \Request ;
6-
75class WebhookSignature
86{
97 /**
Original file line number Diff line number Diff line change @@ -27,21 +27,21 @@ public function setUp(): void
2727 $ this ->webhookCall = $ model ::create ([
2828 'name ' => 'bigbluebutton ' ,
2929 'payload ' => [
30- " event " => [
30+ ' event ' => [
3131 [
32- " data " => [
33- " type " => " event " ,
34- " id " => " my.type " ,
35- " attributes " => [
32+ ' data ' => [
33+ ' type ' => ' event ' ,
34+ ' id ' => ' my.type ' ,
35+ ' attributes ' => [
3636 ],
37- " event " => [
38- " ts " => 1591652302962 ,
37+ ' event ' => [
38+ ' ts ' => 1591652302962 ,
3939 ],
4040 ],
4141 ],
4242 ],
43- " timestamp " => " 1591652302965 " ,
44- " domain " => " example.com " ,
43+ ' timestamp ' => ' 1591652302965 ' ,
44+ ' domain ' => ' example.com ' ,
4545 ],
4646 ]);
4747
Original file line number Diff line number Diff line change 22
33namespace BinaryCats \BigBlueButtonWebhooks \Tests ;
44
5- use Illuminate \Support \Arr ;
65use Illuminate \Support \Facades \Event ;
76use Illuminate \Support \Facades \Route ;
87use Spatie \WebhookClient \Models \WebhookCall ;
@@ -29,7 +28,7 @@ public function it_can_handle_a_valid_request()
2928
3029 $ this
3130 ->withHeaders ([
32- 'Authorization ' => 'Bearer ' . $ this ->determineBigblueButtonsignature ($ payload ),
31+ 'Authorization ' => 'Bearer ' .$ this ->determineBigblueButtonsignature ($ payload ),
3332 ])
3433 ->post ('bigbluebutton-webhooks ' , $ payload )
3534 ->assertSuccessful ();
@@ -75,7 +74,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_
7574
7675 $ this
7776 ->withHeaders ([
78- 'Authorization ' => 'Bearer ' . $ this ->determineBigblueButtonsignature ($ payload ),
77+ 'Authorization ' => 'Bearer ' .$ this ->determineBigblueButtonsignature ($ payload ),
7978 ])
8079 ->post ('bigbluebutton-webhooks ' , $ payload )
8180 ->assertStatus (400 );
@@ -86,7 +85,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_
8685
8786 $ this ->assertFalse (isset ($ webhookCall ->payload ['event ' ][0 ]['data ' ]['id ' ]));
8887 $ this ->assertEquals ([
89- 'invalid_payload '
88+ 'invalid_payload ' ,
9089 ], $ webhookCall ->payload );
9190
9291 $ this ->assertEquals ('Webhook call id `1` did not contain a type. Valid BigBlueButton webhook calls should always contain a type. ' , $ webhookCall ->exception ['message ' ]);
Original file line number Diff line number Diff line change 55class PayloadDefinition
66{
77 /**
8- * Given the compexity of the payload, let's put is all into the same method
8+ * Given the compexity of the payload, let's put is all into the same method.
99 */
1010 public static function getPayloadDefinition (): array
1111 {
1212 return [
13- " event " => [
13+ ' event ' => [
1414 [
15- " data " => [
16- " type " => " event " ,
17- " id " => " my.type " ,
18- " attributes " => [
15+ ' data ' => [
16+ ' type ' => ' event ' ,
17+ ' id ' => ' my.type ' ,
18+ ' attributes ' => [
1919 ],
20- " event " => [
21- " ts " => 1591652302962 ,
20+ ' event ' => [
21+ ' ts ' => 1591652302962 ,
2222 ],
2323 ],
2424 ],
2525 ],
26- " timestamp " => " 1591652302965 " ,
27- " domain " => " example.com " ,
26+ ' timestamp ' => ' 1591652302965 ' ,
27+ ' domain ' => ' example.com ' ,
2828 ];
2929 }
3030}
You can’t perform that action at this time.
0 commit comments