diff --git a/src/Lexicons/App/Bsky/Embed/External.php b/src/Lexicons/App/Bsky/Embed/External.php index 2e0d91b..4441851 100644 --- a/src/Lexicons/App/Bsky/Embed/External.php +++ b/src/Lexicons/App/Bsky/Embed/External.php @@ -101,7 +101,7 @@ public function jsonSerialize(): array 'uri' => $this->uri, 'title' => $this->title, 'description' => $this->description, - 'blob' => ($b = $this->blob) ? $b : null, + 'thumb' => ($b = $this->blob) ? $b : null, ]) ]; } diff --git a/tests/Feature/Lexicons/Com/Atproto/Repo/CreateRecordTest.php b/tests/Feature/Lexicons/Com/Atproto/Repo/CreateRecordTest.php index c017835..86da8fc 100644 --- a/tests/Feature/Lexicons/Com/Atproto/Repo/CreateRecordTest.php +++ b/tests/Feature/Lexicons/Com/Atproto/Repo/CreateRecordTest.php @@ -125,4 +125,36 @@ public function testPostCreationWithoutBlobUploading(): void $this->assertIsString($createdRecord->uri()); } + + public function testPostCreationWithPreviewCard(): void + { + $client = static::$client; + + $uploadedBlob = $client->com()->atproto()->repo()->uploadBlob()->forge() + ->token($client->authenticated()->accessJwt()) + ->blob(__DIR__.'/../../../../../../art/logo-small.webp') + ->send() + ->blob(); + + $external = $client->app()->bsky()->embed()->external()->forge( + 'https://shahmal1yev.dev', + 'Eldar Shahmaliyev\'s blog', + 'A personal blog about cybersecurity and development.' + )->thumb($uploadedBlob); + + $post = $client->app()->bsky()->feed()->post()->forge() + ->text('Come to my blog: ') + ->link('https://shahmal1yev.dev', 'click here and read the posts') + ->embed($external); + + $createRecord = $client->com()->atproto()->repo()->createRecord()->forge() + ->record($post) + ->repo($client->authenticated()->did()) + ->collection($post->nsid()) + ; + + $serializedCreateRecord = json_decode($createRecord, true); + + $this->assertIsArray(Arr::get($serializedCreateRecord, 'record.embed.external.thumb')); + } } diff --git a/tests/Unit/Lexicons/App/Bsky/Embed/ExternalTest.php b/tests/Unit/Lexicons/App/Bsky/Embed/ExternalTest.php index 71757ea..aa4f942 100644 --- a/tests/Unit/Lexicons/App/Bsky/Embed/ExternalTest.php +++ b/tests/Unit/Lexicons/App/Bsky/Embed/ExternalTest.php @@ -128,7 +128,7 @@ public function testJsonSerializeWithSetBlob(): void 'uri' => 'https://shahmal1yev.dev', 'title' => 'foo', 'description' => 'bar', - 'blob' => $this->blob->jsonSerialize() + 'thumb' => $this->blob->jsonSerialize() ], ];