feat: update Bluesky to use public AppView and remove Mastodon access token from public status requests

This commit is contained in:
Paulo Castellano 2026-05-03 22:16:19 -03:00
parent dc75e2b381
commit 5658ea8c8c
3 changed files with 10 additions and 4 deletions

View file

@ -20,13 +20,16 @@ public function fetchPostMetrics(PostPlatform $postPlatform): array
return ['unsupported' => true, 'reason' => 'missing_post_id'];
}
$service = data_get($account->meta, 'service', 'https://bsky.social');
$did = $account->platform_user_id;
$atUri = "at://{$did}/app.bsky.feed.post/{$postPlatform->platform_post_id}";
// Public AppView API: no auth required for reading post counts.
// Read counts (likes, reposts, replies, quotes) live on the AT
// Protocol AppView, not the PDS. The user's PDS requires Bearer auth
// for this endpoint; the public AppView does not.
$appView = (string) config('trypost.platforms.bluesky.public_appview');
$response = $this->socialHttp()
->get("{$service}/xrpc/app.bsky.feed.getPosts", [
->get("{$appView}/xrpc/app.bsky.feed.getPosts", [
'uris' => [$atUri],
]);

View file

@ -22,8 +22,10 @@ public function fetchPostMetrics(PostPlatform $postPlatform): array
$instance = data_get($account->meta, 'instance', 'https://mastodon.social');
// Public posts: no auth needed. Our token only requests write scopes
// (read:accounts + write:statuses + write:media), so attaching the
// Bearer would 403 with "outside the authorized scopes".
$response = $this->socialHttp()
->withToken($account->access_token)
->get("{$instance}/api/v1/statuses/{$postPlatform->platform_post_id}");
if ($response->failed()) {

View file

@ -87,6 +87,7 @@
],
'bluesky' => [
'enabled' => env('BLUESKY_ENABLED', true),
'public_appview' => env('BLUESKY_PUBLIC_APPVIEW', 'https://public.api.bsky.app'),
],
'mastodon' => [
'enabled' => env('MASTODON_ENABLED', true),