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
Centralize AT Protocol NSIDs in BlueskyLexicon
Paulo Castellano8cfdd4c12814
diff --git a/app/Http/Controllers/Auth/BlueskyController.php b/app/Http/Controllers/Auth/BlueskyController.phpindex 4a74d99ae..e262daaaf 100644--- a/app/Http/Controllers/Auth/BlueskyController.php+++ b/app/Http/Controllers/Auth/BlueskyController.php@@ -6,6 +6,7 @@ namespace App\Http\Controllers\Auth;use App\Enums\SocialAccount\Platform as SocialPlatform;use App\Enums\SocialAccount\Status;+use App\Services\Social\BlueskyLexicon;use Illuminate\Http\RedirectResponse;use Illuminate\Http\Request;use Illuminate\Support\Facades\Http;@@ -57,7 +58,7 @@ class BlueskyController extends SocialControllertry {// Authenticate with Bluesky- $response = Http::post("{$service}/xrpc/com.atproto.server.createSession", [+ $response = Http::post("{$service}/xrpc/".BlueskyLexicon::CREATE_SESSION, ['identifier' => $request->identifier,'password' => $request->password,]);@@ -81,7 +82,7 @@ class BlueskyController extends SocialController// Get profile$profileResponse = Http::withToken(data_get($data, 'accessJwt'))- ->get("{$service}/xrpc/app.bsky.actor.getProfile", [+ ->get("{$service}/xrpc/".BlueskyLexicon::GET_PROFILE, ['actor' => data_get($data, 'did'),]);diff --git a/app/Services/Social/BlueskyAnalytics.php b/app/Services/Social/BlueskyAnalytics.phpindex 0ad9d750a..aecb11988 100644--- a/app/Services/Social/BlueskyAnalytics.php+++ b/app/Services/Social/BlueskyAnalytics.php@@ -21,7 +21,7 @@ class BlueskyAnalytics}$did = $account->platform_user_id;- $atUri = "at://{$did}/app.bsky.feed.post/{$postPlatform->platform_post_id}";+ $atUri = "at://{$did}/".BlueskyLexicon::FEED_POST."/{$postPlatform->platform_post_id}";// Read counts (likes, reposts, replies, quotes) live on the AT// Protocol AppView, not the PDS. The user's PDS requires Bearer auth@@ -29,7 +29,7 @@ class BlueskyAnalytics$appView = (string) config('trypost.platforms.bluesky.public_appview');$response = $this->socialHttp()- ->get("{$appView}/xrpc/app.bsky.feed.getPosts", [+ ->get("{$appView}/xrpc/".BlueskyLexicon::GET_POSTS, ['uris' => [$atUri],]);diff --git a/app/Services/Social/BlueskyLexicon.php b/app/Services/Social/BlueskyLexicon.phpnew file mode 100644index 000000000..048f87ae1--- /dev/null+++ b/app/Services/Social/BlueskyLexicon.php@@ -0,0 +1,37 @@+<?php++declare(strict_types=1);++namespace App\Services\Social;++/**+ * AT Protocol / Bluesky lexicon identifiers (NSIDs) used across the Bluesky+ * services. Centralized so a typo surfaces as an undefined-constant error+ * instead of a silent runtime "Invalid request" from the API.+ */+final class BlueskyLexicon+{+ public const RESOLVE_HANDLE = 'com.atproto.identity.resolveHandle';++ public const CREATE_RECORD = 'com.atproto.repo.createRecord';++ public const UPLOAD_BLOB = 'com.atproto.repo.uploadBlob';++ public const CREATE_SESSION = 'com.atproto.server.createSession';++ public const REFRESH_SESSION = 'com.atproto.server.refreshSession';++ public const FEED_POST = 'app.bsky.feed.post';++ public const GET_POSTS = 'app.bsky.feed.getPosts';++ public const GET_PROFILE = 'app.bsky.actor.getProfile';++ public const EMBED_IMAGES = 'app.bsky.embed.images';++ public const FACET_LINK = 'app.bsky.richtext.facet#link';++ public const FACET_MENTION = 'app.bsky.richtext.facet#mention';++ public const FACET_TAG = 'app.bsky.richtext.facet#tag';+}diff --git a/app/Services/Social/BlueskyPublisher.php b/app/Services/Social/BlueskyPublisher.phpindex 23d83bdb2..cc9987180 100644--- a/app/Services/Social/BlueskyPublisher.php+++ b/app/Services/Social/BlueskyPublisher.php@@ -54,7 +54,7 @@ class BlueskyPublisherif (count($images) > 0) {$embed = [- '$type' => 'app.bsky.embed.images',+ '$type' => BlueskyLexicon::EMBED_IMAGES,'images' => $images,];}@@ -66,7 +66,7 @@ class BlueskyPublisher// Create post record$record = [- '$type' => 'app.bsky.feed.post',+ '$type' => BlueskyLexicon::FEED_POST,'text' => $text,'createdAt' => now()->toIso8601ZuluString(),];@@ -80,9 +80,9 @@ class BlueskyPublisher}$response = $this->socialHttp()->withToken($account->access_token)- ->post("{$service}/xrpc/com.atproto.repo.createRecord", [+ ->post("{$service}/xrpc/".BlueskyLexicon::CREATE_RECORD, ['repo' => $account->platform_user_id,- 'collection' => 'app.bsky.feed.post',+ 'collection' => BlueskyLexicon::FEED_POST,'record' => $record,]);@@ -140,7 +140,7 @@ class BlueskyPublisher$response = $this->socialHttp()->withToken($account->access_token)->withHeaders(['Content-Type' => $mimeType])->withBody($stream, $mimeType)- ->post("{$service}/xrpc/com.atproto.repo.uploadBlob");+ ->post("{$service}/xrpc/".BlueskyLexicon::UPLOAD_BLOB);if (is_resource($stream)) {fclose($stream);@@ -192,7 +192,7 @@ class BlueskyPublisher],'features' => [[- '$type' => 'app.bsky.richtext.facet#link',+ '$type' => BlueskyLexicon::FACET_LINK,'uri' => $url,],],@@ -232,7 +232,7 @@ class BlueskyPublisher],'features' => [[- '$type' => 'app.bsky.richtext.facet#mention',+ '$type' => BlueskyLexicon::FACET_MENTION,'did' => $did,],],@@ -260,7 +260,7 @@ class BlueskyPublisher],'features' => [[- '$type' => 'app.bsky.richtext.facet#tag',+ '$type' => BlueskyLexicon::FACET_TAG,'tag' => $tag,],],@@ -283,7 +283,7 @@ class BlueskyPublishertry {$response = $this->socialHttp()->get(- "{$appView}/xrpc/com.atproto.identity.resolveHandle",+ "{$appView}/xrpc/".BlueskyLexicon::RESOLVE_HANDLE,['handle' => $handle],);diff --git a/app/Services/Social/ConnectionVerifier.php b/app/Services/Social/ConnectionVerifier.phpindex 7f25319fa..74cd90e8d 100644--- a/app/Services/Social/ConnectionVerifier.php+++ b/app/Services/Social/ConnectionVerifier.php@@ -167,7 +167,7 @@ class ConnectionVerifiertry {$response = $client->send(fn () => Http::withToken($account->refresh_token)- ->post("{$service}/xrpc/com.atproto.server.refreshSession"));+ ->post("{$service}/xrpc/".BlueskyLexicon::REFRESH_SESSION));$data = $response->json();$account->update([@@ -185,7 +185,7 @@ class ConnectionVerifierif (isset($account->meta['password'])) {try {- $reauth = $client->send(fn () => Http::post("{$service}/xrpc/com.atproto.server.createSession", [+ $reauth = $client->send(fn () => Http::post("{$service}/xrpc/".BlueskyLexicon::CREATE_SESSION, ['identifier' => $account->meta['identifier'],'password' => decrypt($account->meta['password']),]));@@ -490,7 +490,7 @@ class ConnectionVerifier$service = $account->meta['service'] ?? config('trypost.platforms.bluesky.default_service');$response = Http::withToken($account->access_token)- ->get("{$service}/xrpc/app.bsky.actor.getProfile", [+ ->get("{$service}/xrpc/".BlueskyLexicon::GET_PROFILE, ['actor' => $account->platform_user_id,]);