Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Cover mention endpoint fallback and partial resolution
Paulo Castellano9f0c264c39a4
diff --git a/tests/Feature/Services/Social/BlueskyPublisherTest.php b/tests/Feature/Services/Social/BlueskyPublisherTest.phpindex 0c38df33d..d7a296e5e 100644--- a/tests/Feature/Services/Social/BlueskyPublisherTest.php+++ b/tests/Feature/Services/Social/BlueskyPublisherTest.php@@ -169,6 +169,80 @@ test('bluesky publisher skips mention facet when handle cannot be resolved', fun});});+test('bluesky publisher falls back to the public AppView when the PDS cannot resolve', function () {+ $this->post->update(['content' => 'Shout out to @friend.bsky.social']);++ $service = config('trypost.platforms.bluesky.default_service');+ $appView = config('trypost.platforms.bluesky.public_appview');++ Http::fake([+ // The account's PDS fails to resolve; resolution must fall back to the+ // public AppView rather than giving up after the first endpoint.+ $service.'/xrpc/com.atproto.identity.resolveHandle*' => Http::response(['error' => 'InvalidRequest'], 400),+ $appView.'/xrpc/com.atproto.identity.resolveHandle*' => Http::response(['did' => 'did:plc:friend456'], 200),+ $service.'/xrpc/com.atproto.repo.createRecord' => Http::response([+ 'uri' => 'at://did:plc:testuser123/app.bsky.feed.post/3abc123xyz',+ 'cid' => 'bafyreiabc123',+ ], 200),+ ]);++ $this->publisher->publish($this->postPlatform);++ Http::assertSent(function ($request) {+ $record = $request->data()['record'] ?? null;++ if (! $record) {+ return false;+ }++ foreach ($record['facets'] ?? [] as $facet) {+ $feature = $facet['features'][0];+ if ($feature['$type'] === 'app.bsky.richtext.facet#mention') {+ return $feature['did'] === 'did:plc:friend456';+ }+ }++ return false;+ });+});++test('bluesky publisher resolves some mentions and skips the unresolvable ones', function () {+ $this->post->update(['content' => 'cc @good.bsky.social and @bad.bsky.social']);++ Http::fake(function ($request) {+ if (str_contains($request->url(), 'resolveHandle')) {+ // `good` resolves; `bad` answers 200 without a DID — treated as+ // unresolvable, exercising the str_starts_with('did:') guard.+ return str_contains($request->url(), 'good.bsky.social')+ ? Http::response(['did' => 'did:plc:good999'], 200)+ : Http::response([], 200);+ }++ return Http::response([+ 'uri' => 'at://did:plc:testuser123/app.bsky.feed.post/3abc123xyz',+ 'cid' => 'bafyreiabc123',+ ], 200);+ });++ $this->publisher->publish($this->postPlatform);++ Http::assertSent(function ($request) {+ $record = $request->data()['record'] ?? null;++ if (! $record) {+ return false;+ }++ $mentions = collect($record['facets'] ?? [])+ ->filter(fn ($facet) => $facet['features'][0]['$type'] === 'app.bsky.richtext.facet#mention');++ // Only the resolvable handle becomes a facet; the other stays plain text.+ return $mentions->count() === 1+ && $mentions->first()['features'][0]['did'] === 'did:plc:good999'+ && str_contains($record['text'], '@bad.bsky.social');+ });+});+test('bluesky publisher uploads images', function () {// Create a media item through the PostPlatform's media() relation$this->post->update([