Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Jobs/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract class Job
protected $webhookCall;

/**
* Location of the root
* Location of the root.
*
* @var string
*/
Expand All @@ -36,17 +36,17 @@ public function __construct(WebhookCall $webhookCall)
}

/**
* Fetch Payload
* Fetch Payload.
*
* @return array
*/
protected function payload() : array
protected function payload(): array
{
return $this->webhookCall->payload;
}

/**
* Get the value from the payload's event data
* Get the value from the payload's event data.
*
* @param string $key
* @return mixed
Expand Down
4 changes: 0 additions & 4 deletions src/Jobs/MeetingCreatedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

namespace BinaryCats\BigBlueButtonWebhooks\Jobs;

use BinaryCats\BigBlueButtonWebhooks\Jobs\Job;
use Spatie\WebhookClient\Models\WebhookCall;

class MeetingCreatedJob extends Job
{
/**
Expand All @@ -14,6 +11,5 @@ class MeetingCreatedJob extends Job
*/
public function handle()
{

}
}
2 changes: 0 additions & 2 deletions src/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace BinaryCats\BigBlueButtonWebhooks;

use Illuminate\Http\Request;

class Webhook
{
/**
Expand Down
12 changes: 6 additions & 6 deletions src/WebhookCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Spatie\WebhookClient\WebhookConfig;
use Spatie\WebhookClient\Models\WebhookCall as Model;
use Spatie\WebhookClient\WebhookConfig;

class WebhookCall extends Model
{
public static function storeWebhook(WebhookConfig $config, Request $request): WebhookCall
public static function storeWebhook(WebhookConfig $config, Request $request): self
{
# payload is not proper JSON, rather is it split between three blocks
// payload is not proper JSON, rather is it split between three blocks
$payload = $request->input();
# transform event
if ($event = Arr::get($payload, 'event', null) AND is_string($event)) {
// transform event
if ($event = Arr::get($payload, 'event', null) and is_string($event)) {
$payload['event'] = json_decode($event, true);
}
# create
// create
return self::create([
'name' => $config->name,
'payload' => $payload,
Expand Down
2 changes: 0 additions & 2 deletions src/WebhookSignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace BinaryCats\BigBlueButtonWebhooks;

use Illuminate\Http\Request;

class WebhookSignature
{
/**
Expand Down
18 changes: 9 additions & 9 deletions tests/BigBlueButtonWebhookCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ public function setUp(): void
$this->webhookCall = $model::create([
'name' => 'bigbluebutton',
'payload' => [
"event" => [
'event' => [
[
"data" => [
"type" => "event",
"id" => "my.type",
"attributes" => [
'data' => [
'type' => 'event',
'id' => 'my.type',
'attributes' => [
],
"event" => [
"ts" => 1591652302962,
'event' => [
'ts' => 1591652302962,
],
],
],
],
"timestamp" => "1591652302965",
"domain" => "example.com",
'timestamp' => '1591652302965',
'domain' => 'example.com',
],
]);

Expand Down
7 changes: 3 additions & 4 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace BinaryCats\BigBlueButtonWebhooks\Tests;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Route;
use Spatie\WebhookClient\Models\WebhookCall;
Expand All @@ -29,7 +28,7 @@ public function it_can_handle_a_valid_request()

$this
->withHeaders([
'Authorization' => 'Bearer '. $this->determineBigblueButtonsignature($payload),
'Authorization' => 'Bearer '.$this->determineBigblueButtonsignature($payload),
])
->post('bigbluebutton-webhooks', $payload)
->assertSuccessful();
Expand Down Expand Up @@ -75,7 +74,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_

$this
->withHeaders([
'Authorization' => 'Bearer '. $this->determineBigblueButtonsignature($payload),
'Authorization' => 'Bearer '.$this->determineBigblueButtonsignature($payload),
])
->post('bigbluebutton-webhooks', $payload)
->assertStatus(400);
Expand All @@ -86,7 +85,7 @@ public function a_request_with_an_invalid_payload_will_be_logged_but_events_and_

$this->assertFalse(isset($webhookCall->payload['event'][0]['data']['id']));
$this->assertEquals([
'invalid_payload'
'invalid_payload',
], $webhookCall->payload);

$this->assertEquals('Webhook call id `1` did not contain a type. Valid BigBlueButton webhook calls should always contain a type.', $webhookCall->exception['message']);
Expand Down
20 changes: 10 additions & 10 deletions tests/PayloadDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
class PayloadDefinition
{
/**
* Given the compexity of the payload, let's put is all into the same method
* Given the compexity of the payload, let's put is all into the same method.
*/
public static function getPayloadDefinition(): array
{
return [
"event" => [
'event' => [
[
"data" => [
"type" => "event",
"id" => "my.type",
"attributes" => [
'data' => [
'type' => 'event',
'id' => 'my.type',
'attributes' => [
],
"event" => [
"ts" => 1591652302962,
'event' => [
'ts' => 1591652302962,
],
],
],
],
"timestamp" => "1591652302965",
"domain" => "example.com",
'timestamp' => '1591652302965',
'domain' => 'example.com',
];
}
}