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
19
19
protected $ webhookCall ;
20
20
21
21
/**
22
- * Location of the root
22
+ * Location of the root.
23
23
*
24
24
* @var string
25
25
*/
@@ -36,17 +36,17 @@ public function __construct(WebhookCall $webhookCall)
36
36
}
37
37
38
38
/**
39
- * Fetch Payload
39
+ * Fetch Payload.
40
40
*
41
41
* @return array
42
42
*/
43
- protected function payload () : array
43
+ protected function payload (): array
44
44
{
45
45
return $ this ->webhookCall ->payload ;
46
46
}
47
47
48
48
/**
49
- * Get the value from the payload's event data
49
+ * Get the value from the payload's event data.
50
50
*
51
51
* @param string $key
52
52
* @return mixed
Original file line number Diff line number Diff line change 2
2
3
3
namespace BinaryCats \BigBlueButtonWebhooks \Jobs ;
4
4
5
- use BinaryCats \BigBlueButtonWebhooks \Jobs \Job ;
6
- use Spatie \WebhookClient \Models \WebhookCall ;
7
-
8
5
class MeetingCreatedJob extends Job
9
6
{
10
7
/**
@@ -14,6 +11,5 @@ class MeetingCreatedJob extends Job
14
11
*/
15
12
public function handle ()
16
13
{
17
-
18
14
}
19
15
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace BinaryCats \BigBlueButtonWebhooks ;
4
4
5
- use Illuminate \Http \Request ;
6
-
7
5
class Webhook
8
6
{
9
7
/**
Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Http \Request ;
6
6
use Illuminate \Support \Arr ;
7
- use Spatie \WebhookClient \WebhookConfig ;
8
7
use Spatie \WebhookClient \Models \WebhookCall as Model ;
8
+ use Spatie \WebhookClient \WebhookConfig ;
9
9
10
10
class WebhookCall extends Model
11
11
{
12
- public static function storeWebhook (WebhookConfig $ config , Request $ request ): WebhookCall
12
+ public static function storeWebhook (WebhookConfig $ config , Request $ request ): self
13
13
{
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
15
15
$ 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 )) {
18
18
$ payload ['event ' ] = json_decode ($ event , true );
19
19
}
20
- # create
20
+ // create
21
21
return self ::create ([
22
22
'name ' => $ config ->name ,
23
23
'payload ' => $ payload ,
Original file line number Diff line number Diff line change 2
2
3
3
namespace BinaryCats \BigBlueButtonWebhooks ;
4
4
5
- use Illuminate \Http \Request ;
6
-
7
5
class WebhookSignature
8
6
{
9
7
/**
Original file line number Diff line number Diff line change @@ -27,21 +27,21 @@ public function setUp(): void
27
27
$ this ->webhookCall = $ model ::create ([
28
28
'name ' => 'bigbluebutton ' ,
29
29
'payload ' => [
30
- " event " => [
30
+ ' event ' => [
31
31
[
32
- " data " => [
33
- " type " => " event " ,
34
- " id " => " my.type " ,
35
- " attributes " => [
32
+ ' data ' => [
33
+ ' type ' => ' event ' ,
34
+ ' id ' => ' my.type ' ,
35
+ ' attributes ' => [
36
36
],
37
- " event " => [
38
- " ts " => 1591652302962 ,
37
+ ' event ' => [
38
+ ' ts ' => 1591652302962 ,
39
39
],
40
40
],
41
41
],
42
42
],
43
- " timestamp " => " 1591652302965 " ,
44
- " domain " => " example.com " ,
43
+ ' timestamp ' => ' 1591652302965 ' ,
44
+ ' domain ' => ' example.com ' ,
45
45
],
46
46
]);
47
47
Original file line number Diff line number Diff line change 2
2
3
3
namespace BinaryCats \BigBlueButtonWebhooks \Tests ;
4
4
5
- use Illuminate \Support \Arr ;
6
5
use Illuminate \Support \Facades \Event ;
7
6
use Illuminate \Support \Facades \Route ;
8
7
use Spatie \WebhookClient \Models \WebhookCall ;
@@ -29,7 +28,7 @@ public function it_can_handle_a_valid_request()
29
28
30
29
$ this
31
30
->withHeaders ([
32
- 'Authorization ' => 'Bearer ' . $ this ->determineBigblueButtonsignature ($ payload ),
31
+ 'Authorization ' => 'Bearer ' .$ this ->determineBigblueButtonsignature ($ payload ),
33
32
])
34
33
->post ('bigbluebutton-webhooks ' , $ payload )
35
34
->assertSuccessful ();
@@ -75,7 +74,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_
75
74
76
75
$ this
77
76
->withHeaders ([
78
- 'Authorization ' => 'Bearer ' . $ this ->determineBigblueButtonsignature ($ payload ),
77
+ 'Authorization ' => 'Bearer ' .$ this ->determineBigblueButtonsignature ($ payload ),
79
78
])
80
79
->post ('bigbluebutton-webhooks ' , $ payload )
81
80
->assertStatus (400 );
@@ -86,7 +85,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_
86
85
87
86
$ this ->assertFalse (isset ($ webhookCall ->payload ['event ' ][0 ]['data ' ]['id ' ]));
88
87
$ this ->assertEquals ([
89
- 'invalid_payload '
88
+ 'invalid_payload ' ,
90
89
], $ webhookCall ->payload );
91
90
92
91
$ 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 5
5
class PayloadDefinition
6
6
{
7
7
/**
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.
9
9
*/
10
10
public static function getPayloadDefinition (): array
11
11
{
12
12
return [
13
- " event " => [
13
+ ' event ' => [
14
14
[
15
- " data " => [
16
- " type " => " event " ,
17
- " id " => " my.type " ,
18
- " attributes " => [
15
+ ' data ' => [
16
+ ' type ' => ' event ' ,
17
+ ' id ' => ' my.type ' ,
18
+ ' attributes ' => [
19
19
],
20
- " event " => [
21
- " ts " => 1591652302962 ,
20
+ ' event ' => [
21
+ ' ts ' => 1591652302962 ,
22
22
],
23
23
],
24
24
],
25
25
],
26
- " timestamp " => " 1591652302965 " ,
27
- " domain " => " example.com " ,
26
+ ' timestamp ' => ' 1591652302965 ' ,
27
+ ' domain ' => ' example.com ' ,
28
28
];
29
29
}
30
30
}
You can’t perform that action at this time.
0 commit comments