Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/Event/AAclEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function getBoardId(): int {

public function getWebhookSerializable(): array {
return [
'acl' => $this->acl->jsonSerialize(),
'acl' => json_decode(json_encode($this->acl), true),
];
}
}
2 changes: 1 addition & 1 deletion lib/Event/ACardEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function getCard(): Card {

public function getWebhookSerializable(): array {
return [
'card' => $this->card->jsonSerialize(),
'card' => json_decode(json_encode($this->card), true),
];
}
}
20 changes: 20 additions & 0 deletions tests/unit/Event/WebhookCompatibleEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OCA\Deck\Db\Acl;
use OCA\Deck\Db\Card;
use OCA\Deck\Db\Label;
use OCP\EventDispatcher\IWebhookCompatibleEvent;
use Test\TestCase;

Expand All @@ -30,6 +31,25 @@ public function testCardEventIsWebhookCompatible(): void {
$this->assertSame('Test card', $payload['card']['title']);
}

public function testCardEventSerializesNestedEntitiesAsArrays(): void {
$label = new Label();
$label->setId(5);
$label->setTitle('foo');
$label->setColor('ff0000');

$card = new Card();
$card->setId(42);
$card->setTitle('Test card');
$card->setStackId(1);
$card->setLabels([$label]);

$payload = (new CardUpdatedEvent($card))->getWebhookSerializable();

$this->assertIsArray($payload['card']['labels'][0]);
$this->assertSame(5, $payload['card']['labels'][0]['id']);
$this->assertSame('foo', $payload['card']['labels'][0]['title']);
}

public function testAclEventIsWebhookCompatible(): void {
$acl = new Acl();
$acl->setId(7);
Expand Down