Skip to content

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.

Document every MCP and API capability, fix TikTok images and thread reply media (#388)

Paulo Castellano493a288a08bb
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index c55a1127a..c1244046d 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -10,6 +10,10 @@ on:
- develop
- main
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
permissions:
contents: write
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 1fbeefb6a..f4e9630ae 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -6,6 +6,10 @@ on:
pull_request:
branches: [main, develop]
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
env:
DB_CONNECTION: pgsql
DB_DATABASE: trypost_test
@@ -99,8 +103,13 @@ jobs:
- name: Fail unless every engine passed
run: '[ "${{ needs.tests.result }}" = "success" ]'
- e2e:
+ browser:
+ name: Browser (${{ matrix.shard }}/5)
runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ shard: [1, 2, 3, 4, 5]
services:
postgres:
@@ -148,13 +157,23 @@ jobs:
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- run: php artisan test tests/Browser --compact
+ run: php artisan test tests/Browser --compact --shard=${{ matrix.shard }}/5
- name: Upload Playwright artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
- name: playwright-artifacts
+ name: playwright-artifacts-${{ matrix.shard }}
path: tests/Browser/Screenshots
if-no-files-found: ignore
retention-days: 7
+
+ e2e:
+ name: e2e
+ runs-on: ubuntu-latest
+ needs: [browser]
+ if: always()
+
+ steps:
+ - name: Fail unless every browser shard passed
+ run: '[ "${{ needs.browser.result }}" = "success" ]'
diff --git a/AGENTS.md b/AGENTS.md
index c33e1f58d..09f6c426e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -824,7 +824,7 @@ Browser tests live in `tests/Browser` and run on `pestphp/pest-plugin-browser` d
- **Never `sleep()` in a browser test.** The HTTP server that serves the page runs inside the same PHP process (an Amp loop that only ticks while Pest awaits Playwright), so a blocking `sleep()` starves every asset request: the page stays blank, the Vue app never mounts, and screenshots come out empty. Poll from the page with `$page->script(...)` (as the `waitFor*TestId()` helpers do) — that keeps the loop running.
- `BrowserTestCase` sets `$fakesVite = false` on purpose: these tests load real built assets, so faking Vite blanks the app.
- End page assertions with `->assertNoJavaScriptErrors()`.
-- CI runs them un-parallelised (`php artisan test tests/Browser --compact`) against `npm run build` output, so keep them independent of a running dev server.
+- CI runs them in five shards, each serially (`php artisan test tests/Browser --compact --shard=N/5`), against `npm run build` output, so keep them independent of a running dev server and of each other. Several tests still fail on timing under `--parallel`, so do not parallelise a shard until they are fixed; when you do, use `./vendor/bin/pest --parallel`, never `php artisan test --parallel`, which does not start the Playwright server.
## Array Data Access
diff --git a/app/Actions/Analytics/BuildWorkspaceAnalyticsReport.php b/app/Actions/Analytics/BuildWorkspaceAnalyticsReport.php
index f69aa5b5e..de5825c14 100644
--- a/app/Actions/Analytics/BuildWorkspaceAnalyticsReport.php
+++ b/app/Actions/Analytics/BuildWorkspaceAnalyticsReport.php
@@ -81,7 +81,7 @@ class BuildWorkspaceAnalyticsReport
$postAccounts = data_get($publications, 'posts.accounts');
$followerAccounts = data_get($followers, 'followers.accounts');
$performance = data_get($publications, 'performance');
- $statuses = $this->statusesByKey($workspace, [
+ $liveAccounts = $this->liveAccountsByKey($workspace, [
...array_column($postAccounts, 'social_account_key'),
...array_column($followerAccounts, 'social_account_key'),
...array_column($performance, 'social_account_key'),
@@ -122,51 +122,61 @@ class BuildWorkspaceAnalyticsReport
],
'followers' => [
...data_get($followers, 'followers'),
- 'accounts' => $this->withStatus($followerAccounts, $statuses),
+ 'accounts' => $this->withLiveAccount($followerAccounts, $liveAccounts),
],
'posts' => [
...data_get($publications, 'posts'),
- 'accounts' => $this->withStatus($postAccounts, $statuses),
+ 'accounts' => $this->withLiveAccount($postAccounts, $liveAccounts),
],
'top_posts' => [
- 'reactions' => $this->withStatus(data_get($topPosts, 'reactions'), $statuses),
- 'comments' => $this->withStatus(data_get($topPosts, 'comments'), $statuses),
+ 'reactions' => $this->withLiveAccount(data_get($topPosts, 'reactions'), $liveAccounts),
+ 'comments' => $this->withLiveAccount(data_get($topPosts, 'comments'), $liveAccounts),
],
- 'performance' => $this->withStatus($performance, $statuses),
+ 'performance' => $this->withLiveAccount($performance, $liveAccounts),
'coverage' => $this->coverage($workspace, $channelKeys === null ? null : array_keys($channelKeys)),
];
}
/**
- * The live connection status of each key that is still a social account of the workspace;
- * a key whose account is gone is absent, so its row carries no status.
+ * The live connection status and current avatar of each key that is still a
+ * social account of the workspace. A key whose account is gone is absent, so
+ * its row keeps no status, and a row without a live avatar keeps the one its
+ * analytics rows stored.
*
* @param list<string> $keys
- * @return array<string, string>
+ * @return array<string, array{status: string, avatar_url: string|null}>
*/
- private function statusesByKey(Workspace $workspace, array $keys): array
+ private function liveAccountsByKey(Workspace $workspace, array $keys): array
{
$ids = array_values(array_unique(array_filter($keys, fn (string $key): bool => Str::isUuid($key))));
return SocialAccount::query()
->whereBelongsTo($workspace)
->whereIn('id', $ids)
- ->get(['id', 'status'])
- ->mapWithKeys(fn (SocialAccount $account): array => [$account->id => $account->status->value])
+ ->get(['id', 'status', 'avatar_url'])
+ ->mapWithKeys(fn (SocialAccount $account): array => [$account->id => [
+ 'status' => $account->status->value,
+ 'avatar_url' => $account->avatar_url,
+ ]])
->all();
}
/**
* @param list<array<string, mixed>> $rows
- * @param array<string, string> $statuses
+ * @param array<string, array{status: string, avatar_url: string|null}> $liveAccounts
* @return list<array<string, mixed>>
*/
- private function withStatus(array $rows, array $statuses): array
+ private function withLiveAccount(array $rows, array $liveAccounts): array
{
- return array_map(fn (array $row): array => [
- ...$row,
- 'status' => data_get($statuses, data_get($row, 'social_account_key')),
- ], $rows);
+ return array_map(function (array $row) use ($liveAccounts): array {
+ $live = data_get($liveAccounts, data_get($row, 'social_account_key'));
+
+ return [
+ ...$row,
+ 'avatar_url' => data_get($live, 'avatar_url') ?? data_get($row, 'avatar_url'),
+ 'status' => data_get($live, 'status'),
+ ];
+ }, $rows);
}
/**
diff --git a/app/Actions/Analytics/ReadPublicationAnalytics.php b/app/Actions/Analytics/ReadPublicationAnalytics.php
index 43a769874..ee49ad844 100644
--- a/app/Actions/Analytics/ReadPublicationAnalytics.php
+++ b/app/Actions/Analytics/ReadPublicationAnalytics.php
@@ -26,6 +26,7 @@ class ReadPublicationAnalytics
public function latestForWorkspacePublication(Workspace $workspace, string $publicationId): array
{
$publication = AnalyticsPublication::query()
+ ->with('socialAccount')
->available()
->whereBelongsTo($workspace)
->whereIn('platform', Platform::analyticsValues())
@@ -102,7 +103,10 @@ class ReadPublicationAnalytics
return [$destination->id => $this->unavailable('platform_not_supported')];
}
- $publication = $publications->get($destination->id);
+ $publication = $publications->get($destination->id)?->setRelation(
+ 'socialAccount',
+ $destination->relationLoaded('socialAccount') ? $destination->socialAccount : null,
+ );
return [$destination->id => $publication
? $this->detail($publication, $snapshots->get($publication->id))
@@ -122,6 +126,7 @@ class ReadPublicationAnalytics
}
$publication = AnalyticsPublication::query()
+ ->with('socialAccount')
->available()
->where('workspace_id', $postPlatform->post->workspace_id)
->where('post_platform_id', $postPlatform->id)
@@ -166,6 +171,8 @@ class ReadPublicationAnalytics
/** @return array<string, mixed> */
private function detail(AnalyticsPublication $publication, ?AnalyticsPublicationDailySnapshot $snapshot): array
{
+ $publication->loadMissing('socialAccount');
+
return [
'available' => true,
'reason' => null,
@@ -183,7 +190,7 @@ class ReadPublicationAnalytics
'preview_metadata' => $publication->preview_metadata,
'account_display_name' => $publication->account_display_name,
'account_username' => $publication->account_username,
- 'account_avatar_url' => $publication->account_avatar_url,
+ 'account_avatar_url' => $publication->socialAccount?->avatar_url ?? $publication->account_avatar_url,
],
'snapshot' => $snapshot ? $this->snapshot($snapshot) : null,
'metrics' => $snapshot ? $this->withEngagementRate($snapshot) : [],
diff --git a/app/Actions/Analytics/SyncTryPostPublication.php b/app/Actions/Analytics/SyncTryPostPublication.php
index cc6076c26..f219eb292 100644
--- a/app/Actions/Analytics/SyncTryPostPublication.php
+++ b/app/Actions/Analytics/SyncTryPostPublication.php
@@ -10,6 +10,7 @@ use App\Enums\PostPlatform\ContentType;
use App\Models\AnalyticsPublication;
use App\Models\PostPlatform;
use App\Models\SocialAccount;
+use App\Services\Social\ContentSanitizer;
use Illuminate\Support\Str;
use LogicException;
@@ -82,7 +83,7 @@ class SyncTryPostPublication
private function excerpt(PostPlatform $postPlatform): ?string
{
- $content = trim(html_entity_decode(strip_tags((string) $postPlatform->post?->content)));
+ $content = app(ContentSanitizer::class)->plainText((string) $postPlatform->post?->content);
return $content === '' ? null : Str::limit($content, 500);
}
diff --git a/app/Actions/Post/HostInlineMedia.php b/app/Actions/Post/HostInlineMedia.php
index 7a5f89369..3e9b380e8 100644
--- a/app/Actions/Post/HostInlineMedia.php
+++ b/app/Actions/Post/HostInlineMedia.php
@@ -48,7 +48,29 @@ class HostInlineMedia
}
}
- return $data;
+ return self::threadReplies($workspace, $data, 'destinations', $fetched);
+ }
+
+ /**
+ * Host the media of a single post request and of the thread replies of
+ * its targets (`platforms.*.meta.thread_replies.*.media`), so a URL is
+ * accepted wherever a post takes media.
+ *
+ * @param array<MediaType> $allowedTypes
+ * @param array<string, mixed> $data
+ * @return array<string, mixed>
+ *
+ * @throws ValidationException
+ */
+ public static function forPost(Workspace $workspace, array $allowedTypes, array $data): array
+ {
+ $fetched = [];
+
+ if (array_key_exists('media', $data)) {
+ $data['media'] = self::execute($workspace, $allowedTypes, $data['media'], fetched: $fetched);
+ }
+
+ return self::threadReplies($workspace, $data, 'platforms', $fetched);
}
/**
@@ -123,6 +145,40 @@ class HostInlineMedia
}
}
+ /**
+ * Host the reply media of every target listed under `$listKey` that
+ * carries a URL. Replies sent only as ids or upload tokens are left for
+ * the save to resolve, as before.
+ *
+ * @param array<string, mixed> $data
+ * @param array<string, string> $fetched
+ * @return array<string, mixed>
+ *
+ * @throws ValidationException
+ */
+ private static function threadReplies(Workspace $workspace, array $data, string $listKey, array &$fetched): array
+ {
+ foreach ((array) data_get($data, $listKey, []) as $target => $entry) {
+ foreach ((array) data_get($entry, 'meta.thread_replies', []) as $index => $reply) {
+ $media = (array) data_get($reply, 'media', []);
+
+ if (! collect($media)->contains(fn (mixed $item): bool => filled(data_get($item, 'url')))) {
+ continue;
+ }
+
+ $data[$listKey][$target]['meta']['thread_replies'][$index]['media'] = self::execute(
+ $workspace,
+ MediaType::cases(),
+ $media,
+ "{$listKey}.{$target}.meta.thread_replies.{$index}.media",
+ $fetched,
+ );
+ }
+ }
+
+ return $data;
+ }
+
/**
* The row as the composer shape the save validates, with the client's
* editable meta (alt text, user tags) on top of what is stored. The `alt`
diff --git a/app/Actions/Post/ImportExternalPosts.php b/app/Actions/Post/ImportExternalPosts.php
index 7a6c5dc69..563bb92c8 100644
--- a/app/Actions/Post/ImportExternalPosts.php
+++ b/app/Actions/Post/ImportExternalPosts.php
@@ -227,7 +227,7 @@ class ImportExternalPosts
private static function sentPostsMatching(SocialAccount $account, AnalyticsPublication $publication): Collection
{
$window = (int) config('trypost.external_posts.match_window_minutes');
- $text = self::normalizedText((string) $publication->excerpt);
+ $text = Str::squish((string) $publication->excerpt);
if ($window < 1 || $text === '' || ! in_array($account->platform, self::PROVISIONAL_ID_PLATFORMS, true)) {
return new Collection;
@@ -274,7 +274,7 @@ class ImportExternalPosts
*/
private static function sameText(string $content, string $text, Platform $platform): bool
{
- $sent = self::normalizedText(app(ContentSanitizer::class)->displayText($content, $platform));
+ $sent = Str::squish(app(ContentSanitizer::class)->displayText($content, $platform));
if ($sent === '') {
return false;
@@ -291,13 +291,6 @@ class ImportExternalPosts
&& str_starts_with($sent, $truncated);
}
- private static function normalizedText(string $text): string
- {
- $plain = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
-
- return trim((string) preg_replace('/\s+/u', ' ', $plain));
- }
-
private static function createPost(SocialAccount $account, AnalyticsPublication $publication): PostPlatform
{
$publishedAt = $publication->provider_published_at;
diff --git a/app/Enums/PostPlatform/ContentType.php b/app/Enums/PostPlatform/ContentType.php
index 0001c2fa0..e68193aad 100644
--- a/app/Enums/PostPlatform/ContentType.php
+++ b/app/Enums/PostPlatform/ContentType.php
@@ -8,6 +8,7 @@ use App\Dto\MediaItem;
use App\Enums\Analytics\PublicationContentType;
use App\Enums\Media\Type as MediaType;
use App\Enums\SocialAccount\Platform as SocialPlatform;
+use App\Support\ThreadReplies;
enum ContentType: string
{
@@ -603,7 +604,11 @@ enum ContentType: string
* image_max_height: int|null,
* supports_alt_text: bool,
* supports_user_tags: bool,
- * supports_video_cover: bool
+ * supports_video_cover: bool,
+ * captionless: bool,
+ * document_must_be_alone: bool,
+ * supports_thread_replies: bool,
+ * max_thread_replies: int|null
* }
*/
public function toListingArray(): array
@@ -641,6 +646,10 @@ enum ContentType: string
'supports_user_tags',
'supports_video_cover',
])),
+ 'captionless' => $this->isCaptionless(),
+ 'document_must_be_alone' => $this->supportsDocument(),
+ 'supports_thread_replies' => ThreadReplies::supports($this->platform()),
+ 'max_thread_replies' => ThreadReplies::supports($this->platform()) ? ThreadReplies::MAX_REPLIES : null,
];
}
diff --git a/app/Enums/SocialAccount/Platform.php b/app/Enums/SocialAccount/Platform.php
index bc664eb33..20e3ff754 100644
--- a/app/Enums/SocialAccount/Platform.php
+++ b/app/Enums/SocialAccount/Platform.php
@@ -138,7 +138,7 @@ enum Platform: string
return match ($this) {
self::LinkedIn, self::LinkedInPage => [MediaType::Image, MediaType::Video, MediaType::Document],
self::X => [MediaType::Image, MediaType::Video],
- self::TikTok => [MediaType::Video],
+ self::TikTok => [MediaType::Image, MediaType::Video],
self::YouTube => [MediaType::Video],
self::Facebook => [MediaType::Image, MediaType::Video],
self::Instagram, self::InstagramFacebook => [MediaType::Image, MediaType::Video],
diff --git a/app/Http/Controllers/Api/PostController.php b/app/Http/Controllers/Api/PostController.php
index 091e614c2..99fa0892f 100644
--- a/app/Http/Controllers/Api/PostController.php
+++ b/app/Http/Controllers/Api/PostController.php
@@ -76,13 +76,7 @@ class PostController extends Controller
$workspace = $request->user()->currentWorkspace;
$data = $request->validated();
- if (array_key_exists('media', $data)) {
- $data['media'] = HostInlineMedia::execute(
- $workspace,
- Post::allowedMediaTypesFor($request->selectedPlatforms()),
- $data['media'],
- );
- }
+ $data = HostInlineMedia::forPost($workspace, Post::allowedMediaTypesFor($request->selectedPlatforms()), $data);
$post = CreatePosts::execute($workspace, $request->user(), [
'status' => $data['status'] ?? 'draft',
@@ -126,13 +120,7 @@ class PostController extends Controller
$data = $request->validated();
- if (array_key_exists('media', $data)) {
- $data['media'] = HostInlineMedia::execute(
- $request->user()->currentWorkspace,
- $post->allowedMediaTypes(),
- $data['media'],
- );
- }
+ $data = HostInlineMedia::forPost($request->user()->currentWorkspace, $post->allowedMediaTypes(), $data);
$result = UpdatePost::execute($request->user()->currentWorkspace, $post, $data, $request->user());
diff --git a/app/Http/Controllers/Api/WorkspaceController.php b/app/Http/Controllers/Api/WorkspaceController.php
index c7d4f080b..db298f5d0 100644
--- a/app/Http/Controllers/Api/WorkspaceController.php
+++ b/app/Http/Controllers/Api/WorkspaceController.php
@@ -11,6 +11,6 @@ class WorkspaceController extends Controller
{
public function show(Request $request): WorkspaceResource
{
- return new WorkspaceResource($request->user()->currentWorkspace);
+ return (new WorkspaceResource($request->user()->currentWorkspace))->for($request->user());
}
}
diff --git a/app/Http/Resources/Api/PlatformContentTypesResource.php b/app/Http/Resources/Api/PlatformContentTypesResource.php
index bc902a4c7..0680b80b9 100644
--- a/app/Http/Resources/Api/PlatformContentTypesResource.php
+++ b/app/Http/Resources/Api/PlatformContentTypesResource.php
@@ -6,6 +6,7 @@ namespace App\Http\Resources\Api;
use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
+use App\Support\PostPlatformMetaRules;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
@@ -29,6 +30,9 @@ class PlatformContentTypesResource extends JsonResource
'platform' => $platform->value,
'label' => $platform->label(),
'max_content_length' => $platform->maxContentLength(),
+ 'max_hashtags' => $platform->maxHashtags(),
+ 'alt_text_max_length' => $platform->altTextMaxLength(),
+ 'required_meta' => PostPlatformMetaRules::requiredMetaKeys($platform),
'recommended_content_length' => $platform->recommendedAiContentLength(),
'allowed_media_types' => array_map(
fn ($type) => $type->value,
diff --git a/app/Http/Resources/Api/SocialAccountResource.php b/app/Http/Resources/Api/SocialAccountResource.php
index f02bfe87a..07c36bf56 100644
--- a/app/Http/Resources/Api/SocialAccountResource.php
+++ b/app/Http/Resources/Api/SocialAccountResource.php
@@ -23,6 +23,9 @@ class SocialAccountResource extends JsonResource
'has_posting_schedule' => $this->hasPostingSchedule(),
'timezone' => $this->timezone,
'posting_goal' => $this->posting_goal,
+ 'max_content_length' => $this->maxContentLength(),
+ 'long_posts' => $this->hasXLongPosts(),
+ 'verified_badge' => $this->verified_badge,
];
}
}
diff --git a/app/Http/Resources/Api/WorkspaceResource.php b/app/Http/Resources/Api/WorkspaceResource.php
index 94be3e075..6339f5049 100644
--- a/app/Http/Resources/Api/WorkspaceResource.php
+++ b/app/Http/Resources/Api/WorkspaceResource.php
@@ -4,11 +4,24 @@ declare(strict_types=1);
namespace App\Http\Resources\Api;
+use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class WorkspaceResource extends JsonResource
{
+ private ?User $viewer = null;
+
+ /**
+ * Include what this user may do in the workspace as `me`.
+ */
+ public function for(User $viewer): static
+ {
+ $this->viewer = $viewer;
+
+ return $this;
+ }
+
/**
* @return array<string, mixed>
*/
@@ -19,6 +32,11 @@ class WorkspaceResource extends JsonResource
'name' => $this->name,
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
'updated_at' => $this->updated_at->format('Y-m-d H:i:s'),
+ 'me' => $this->when($this->viewer !== null, fn (): array => [
+ 'is_admin' => $this->viewer->isWorkspaceAdmin($this->resource),
+ 'requires_approval' => $this->viewer->requiresApprovalIn($this->resource),
+ 'publishes_directly' => $this->viewer->canPublishDirectlyIn($this->resource),
+ ]),
];
}
}
diff --git a/app/Mcp/Concerns/DescribesPostMedia.php b/app/Mcp/Concerns/DescribesPostMedia.php
index e0e429794..32056813a 100644
--- a/app/Mcp/Concerns/DescribesPostMedia.php
+++ b/app/Mcp/Concerns/DescribesPostMedia.php
@@ -18,11 +18,11 @@ trait DescribesPostMedia
return $schema->array()
->items($schema->object(fn (JsonSchema $item): array => [
'upload_token' => $item->string()->description('Token of a file uploaded earlier with request-media-upload-tool; valid once, before it expires. To use the same file on another post, pass the media id the first post returned.'),
- 'url' => $item->string()->description('Public http(s) URL that serves the file itself (an image, video or PDF; redirects are not followed and web pages are refused); downloaded once per call.'),
+ 'url' => $item->string()->description('Public http(s) URL that serves the file itself (a JPEG, PNG, GIF or WebP image, HEIC or HEIF when the server can convert it, an MP4 or MOV video, or a PDF; redirects are not followed and web pages are refused); downloaded once per call, within 20 seconds, up to the server limits (by default 10 MB and 67 megapixels for an image, 1 GB for a video, 100 MB for a PDF).'),
'id' => $item->string()->description('UUID of a media item of this workspace, as returned in a post\'s media (get-post-tool, list-posts-tool); copied for the post. An id already on the post keeps it, so send the current ids in the new order to reorder, and leave one out to remove it.'),
'alt' => $item->string()->description('Alt text for an image (ignored for video and PDF).'),
- 'meta' => $item->object()->description('Per-item settings: alt_text (string, up to 2000 characters), user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover).'),
+ 'meta' => $item->object()->description('Per-item settings: alt_text (string, up to 2000 characters; cut to the network limit, alt_text_max_length in list-content-types-tool, when published), user_tags (Instagram feed images only: up to 20 of {username, x, y}, x and y between 0 and 1 from the top-left corner), cover_offset_ms (video cover frame in milliseconds, for content types with supports_video_cover).'),
]))
- ->description("{$description} Items keep the order given (the first is the cover of a carousel). Each item gives exactly one of upload_token, url or id. Check the content type's media rules with list-content-types-tool.");
+ ->description("{$description} Items keep the order given (the first is the cover of a carousel). Each item gives exactly one of upload_token, url or id. A PDF must be the only attachment. Check the content type's media rules with list-content-types-tool.");
}
}
diff --git a/app/Mcp/Servers/TryPostServer.php b/app/Mcp/Servers/TryPostServer.php
index a81c35b86..0d3bc24b8 100644
--- a/app/Mcp/Servers/TryPostServer.php
+++ b/app/Mcp/Servers/TryPostServer.php
@@ -94,7 +94,7 @@ use Laravel\Mcp\Server\Attributes\Version;
#[Name('TryPost')]
#[Version('1.0.0')]
#[Icon('images/trypost/icon.png', mimeType: 'image/png')]
-#[Instructions('TryPost is a social media scheduling platform. Use this server to manage posts, analytics, signatures, labels, social accounts, workspaces, outgoing webhooks, repurposes (auto-replicating videos posted outside TryPost), and API keys. Media is attached to a post by upload or URL; an upload is temporary, kept for 24 hours and single-use, and every post keeps its own copy of its files. Members who need approval in a workspace can create and edit posts, but scheduling, queueing or publishing stores their post with status pending_approval until a member who publishes directly calls approve-post-tool or reject-post-tool.')]
+#[Instructions('TryPost is a social media scheduling platform. Use this server to manage posts (drafts, custom times, the channel queue and its free slots, recurrence, threads on X, Bluesky and Mastodon through meta.thread_replies, previews, notes and approvals), ideas, analytics, signatures, labels, social accounts and their posting times, workspaces, outgoing webhooks, repurposes (auto-replicating videos posted outside TryPost), and API keys. Call list-content-types-tool before choosing a content_type or attaching media: it lists the media rules, text and hashtag limits, thread support and the meta each network requires. Media is attached to a post by upload or URL; an upload is temporary, kept for 24 hours and single-use, and every post keeps its own copy of its files. Times are UTC. Members who need approval in a workspace can create and edit posts, but scheduling, queueing or publishing stores their post with status pending_approval until a member who publishes directly calls approve-post-tool or reject-post-tool; get-workspace-tool tells the caller which applies.')]
class TryPostServer extends Server
{
public int $defaultPaginationLength = 100;
diff --git a/app/Mcp/Tools/Idea/CreateIdeaTool.php b/app/Mcp/Tools/Idea/CreateIdeaTool.php
index 0d7738df4..60d7185c2 100644
--- a/app/Mcp/Tools/Idea/CreateIdeaTool.php
+++ b/app/Mcp/Tools/Idea/CreateIdeaTool.php
@@ -45,9 +45,9 @@ class CreateIdeaTool extends Tool
{
return [
'title' => $schema->string()->description('The idea title (max 255 characters).'),
- 'body' => $schema->string()->description('The idea text.'),
+ 'body' => $schema->string()->description('The idea text, up to 10000 characters.'),
'idea_stage_id' => $schema->string()->description('The stage ID; omit for no stage.'),
- 'media_ids' => $schema->array()->items($schema->string())->description('Media IDs from the current workspace (max 10).'),
+ 'media_ids' => $schema->array()->items($schema->string())->description('IDs of media already in the current workspace (max 10), for example from a post media; upload tokens and URLs are not accepted.'),
'label_ids' => $schema->array()->items($schema->string())->description('Label IDs from the current workspace.'),
];
}
diff --git a/app/Mcp/Tools/Idea/UpdateIdeaTool.php b/app/Mcp/Tools/Idea/UpdateIdeaTool.php
index 29f56a594..26da5b22b 100644
--- a/app/Mcp/Tools/Idea/UpdateIdeaTool.php
+++ b/app/Mcp/Tools/Idea/UpdateIdeaTool.php
@@ -60,9 +60,9 @@ class UpdateIdeaTool extends Tool
return [
'idea_id' => $schema->string()->required()->description('The idea ID.'),
'title' => $schema->string()->description('The idea title (max 255 characters).'),
- 'body' => $schema->string()->description('The idea text.'),
+ 'body' => $schema->string()->description('The idea text, up to 10000 characters.'),
'idea_stage_id' => $schema->string()->description('Move the idea to this stage ID (placed last); to move an idea to no stage use move-ideas-tool.'),
- 'media_ids' => $schema->array()->items($schema->string())->description('The full media ID list (max 10).'),
+ 'media_ids' => $schema->array()->items($schema->string())->description('The full list of IDs of media already in the current workspace (max 10); upload tokens and URLs are not accepted.'),
'label_ids' => $schema->array()->items($schema->string())->description('The full label ID list.'),
];
}
diff --git a/app/Mcp/Tools/Label/CreateLabelTool.php b/app/Mcp/Tools/Label/CreateLabelTool.php
index b6f43adb3..0f8f17945 100644
--- a/app/Mcp/Tools/Label/CreateLabelTool.php
+++ b/app/Mcp/Tools/Label/CreateLabelTool.php
@@ -40,7 +40,7 @@ class CreateLabelTool extends Tool
{
return [
'name' => $schema->string()->required()->description('The label name.'),
- 'color' => $schema->string()->required()->description('Hex color code (e.g. #FF5733).'),
+ 'color' => $schema->string()->required()->description('Hex color as #RRGGBB with the leading # (e.g. #FF5733).'),
];
}
}
diff --git a/app/Mcp/Tools/Label/UpdateLabelTool.php b/app/Mcp/Tools/Label/UpdateLabelTool.php
index 4a3f2a872..252b3a8e8 100644
--- a/app/Mcp/Tools/Label/UpdateLabelTool.php
+++ b/app/Mcp/Tools/Label/UpdateLabelTool.php
@@ -49,7 +49,7 @@ class UpdateLabelTool extends Tool
return [
'label_id' => $schema->string()->required()->description('The label ID.'),
'name' => $schema->string()->required()->description('The new name.'),
- 'color' => $schema->string()->required()->description('Hex color code (e.g. #FF5733).'),
+ 'color' => $schema->string()->required()->description('Hex color as #RRGGBB with the leading # (e.g. #FF5733).'),
];
}
}
diff --git a/app/Mcp/Tools/Platform/ListContentTypesTool.php b/app/Mcp/Tools/Platform/ListContentTypesTool.php
index ac77c2d79..910baa91a 100644
--- a/app/Mcp/Tools/Platform/ListContentTypesTool.php
+++ b/app/Mcp/Tools/Platform/ListContentTypesTool.php
@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Mcp\Tools\Platform;
-use App\Enums\PostPlatform\ContentType;
use App\Enums\SocialAccount\Platform;
+use App\Http\Resources\Api\PlatformContentTypesResource;
use App\Mcp\Concerns\AuthorizesMcpTool;
use App\Models\Workspace;
use Laravel\Mcp\Request;
@@ -16,7 +16,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('List the valid content_types per social platform plus their media constraints: max/min media count, requires_media, accept_images/accept_videos/accept_documents, accepts_gif, accepts_mov, forbids_mixed_media, max_video_duration_sec (null = no cap), max_image_bytes / max_video_bytes / max_document_bytes, aspect_ratio_min / aspect_ratio_max for images and video_aspect_ratio_min / video_aspect_ratio_max for videos (width / height, the range the network accepts, null = not checked; GIFs are never checked; auto_fits_image when images are fitted into the frame on publish instead), image_min_width / image_min_height / image_max_width / image_max_height in pixels, supports_alt_text, supports_user_tags (Instagram tags in media meta.user_tags) and supports_video_cover (meta.cover_offset_ms), and the platform default_content_type. These caps mirror each network\'s official limits and are enforced when a post is scheduled, queued or published (create-post-tool, create-posts-tool, update-post-tool, publish-post-tool): a post whose media breaks a rule of its content_type is rejected with a per-platform error. Drafts are never blocked. Call this before attaching media or choosing a content_type.')]
+#[Description('List every platform with its content types and their rules. Per content type: max/min media count, requires_media, accept_images/accept_videos/accept_documents, accepts_gif, accepts_mov, forbids_mixed_media, max_video_duration_sec (null = no cap), max_image_bytes / max_video_bytes / max_document_bytes, aspect_ratio_min / aspect_ratio_max for images and video_aspect_ratio_min / video_aspect_ratio_max for videos (width / height, null = not checked; GIFs are never checked; auto_fits_image when images are fitted into the frame on publish instead), image_min_width / image_min_height / image_max_width / image_max_height in pixels, supports_alt_text, supports_user_tags (Instagram tags in media meta.user_tags), supports_video_cover (meta.cover_offset_ms), captionless (stories publish no text, so the text is neither sent nor measured), document_must_be_alone (a PDF must be the only attachment), supports_thread_replies and max_thread_replies (threads on X, Bluesky and Mastodon through meta.thread_replies). Per platform: allowed_media_types, default_content_type, max_content_length (the default text limit of the network; the limit of each account, such as 25000 for an X account with long posts, is max_content_length in list-social-accounts-tool), max_hashtags (Instagram: 5), alt_text_max_length and required_meta (meta needed before a post is scheduled or published; Google Business events and offers also need meta.event, and a YouTube post needs meta.title or text). Media rules never block a draft: they are checked when a post is scheduled, queued or published (create-post-tool, create-posts-tool, update-post-tool, publish-post-tool), and a post whose media breaks a rule of its content_type is rejected with a per-platform error. Call this before attaching media or choosing a content_type.')]
class ListContentTypesTool extends Tool
{
use AuthorizesMcpTool;
@@ -29,28 +29,8 @@ class ListContentTypesTool extends Tool
return $workspace;
}
- $platforms = [];
-
- foreach (Platform::cases() as $platform) {
- $contentTypes = array_map(
- fn (ContentType $type) => $type->toListingArray(),
- array_values(ContentType::forPlatform($platform)),
- );
-
- $platforms[] = [
- 'platform' => $platform->value,
- 'label' => $platform->label(),
- 'max_content_length' => $platform->maxContentLength(),
- 'recommended_content_length' => $platform->recommendedAiContentLength(),
- 'allowed_media_types' => array_map(
- fn ($type) => $type->value,
- $platform->allowedMediaTypes(),
- ),
- 'default_content_type' => ContentType::defaultFor($platform)->value,
- 'content_types' => $contentTypes,
- ];
- }
-
- return Response::structured(['platforms' => $platforms]);
+ return Response::structured([
+ 'platforms' => PlatformContentTypesResource::collection(Platform::cases())->resolve(),
+ ]);
}
}
diff --git a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
index 049f849d5..a1107d100 100644
--- a/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
+++ b/app/Mcp/Tools/Post/AttachMediaFromUploadTool.php
@@ -19,7 +19,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Attach a Media uploaded via request-media-upload-tool to a post. The upload_token is the value returned by request-media-upload-tool; the Media is resolved by that token within the current workspace, then appended after the post\'s current media (to reorder or remove media, call update-post-tool with the media ids in the new order). The media type must be accepted by the post\'s channel and content type. A post that is publishing or already published cannot change; a scheduled post edited by a member who needs approval goes back to pending_approval. Size, video duration, GIF and MOV caps per content_type (see list-content-types-tool) are checked when the post is scheduled or published, not here.')]
+#[Description('Attach a file uploaded with request-media-upload-tool to a post. The upload_token is the value request-media-upload-tool returned; the file is resolved by that token within the current workspace, then appended after the post media (to reorder or remove media, call update-post-tool with the media ids in the new order). The file type must be one the post channel accepts (allowed_media_types in list-content-types-tool). Posts that are publishing, published, partially_published or failed cannot change; a scheduled post edited by a member who needs approval goes back to pending_approval. Size, video duration, GIF and MOV caps per content_type (see list-content-types-tool) are checked when the post is scheduled or published, not here. Media is added to the post itself; to give a thread reply its own media, pass the upload_token in meta.thread_replies with update-post-tool.')]
class AttachMediaFromUploadTool extends Tool
{
use AuthorizesMcpTool;
@@ -70,7 +70,7 @@ class AttachMediaFromUploadTool extends Tool
{
return [
'post_id' => $schema->string()->required()->description('UUID of the post to attach the uploaded media to.'),
- 'upload_token' => $schema->string()->required()->description('upload_token returned by RequestMediaUploadTool, after the user has POSTed the file to the upload_url.'),
+ 'upload_token' => $schema->string()->required()->description('upload_token returned by request-media-upload-tool, after the file was sent to its upload_url.'),
'alt' => $schema->string()->description('Optional accessibility alt text for the media (applies to images).'),
];
}
diff --git a/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
index 5f04c0a43..7ffbf5078 100644
--- a/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
+++ b/app/Mcp/Tools/Post/AttachMediaFromUrlTool.php
@@ -17,7 +17,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Download images, videos, or PDF documents from public URLs and attach them to a post. Each URL is fetched, stored, and registered as a Media record on the workspace. The media is appended after the post\'s current media. Each URL must serve the file itself: redirects are not followed, and web pages, private-network hosts and files over the type\'s size ceiling are refused. Only the types the post\'s channel accepts are kept. URLs that could not be attached are listed in failed_urls, and failures gives the reason of each (unreachable, type_not_allowed, too_large, host_not_allowed) with a message. Video duration is measured on the server. Per-network size, duration, GIF and MOV caps (see list-content-types-tool) are enforced when the post is scheduled or published.')]
+#[Description('Download images, videos, or PDF documents from public URLs and attach them to a post. Each URL is fetched, stored, and registered as a Media record on the workspace. The media is appended after the post\'s current media. Each URL must serve the file itself: redirects are not followed, and web pages, private-network hosts and files over the type\'s size ceiling are refused. Only the types the post\'s channel accepts are kept. URLs that could not be attached are listed in failed_urls, and failures gives the reason of each (unreachable, type_not_allowed, too_large, host_not_allowed) with a message. Video duration is measured on the server. Per-network size, duration, GIF and MOV caps (see list-content-types-tool) are enforced when the post is scheduled or published. Supported files: JPEG, PNG, GIF and WebP images (HEIC and HEIF too when the server can convert them), MP4 and MOV videos, and PDF. Each download must finish within 20 seconds and fit the server limits (by default 10 MB and 67 megapixels for an image, 1 GB for a video, 100 MB for a PDF). Media is added to the post itself; to give a thread reply its own media, pass it in meta.thread_replies with update-post-tool.')]
class AttachMediaFromUrlTool extends Tool
{
use AuthorizesMcpTool;
@@ -67,7 +67,7 @@ class AttachMediaFromUrlTool extends Tool
'alt' => $u->string()->description('Optional accessibility alt text for the image (ignored for video/PDF, which have no alt text).'),
]))
->required()
- ->description('Media to attach. Max 10 per call. Allowed types: image/jpeg, image/png, image/gif, image/webp, video/mp4, video/quicktime, application/pdf. The workspace-wide per-type size ceilings apply on download; stricter per-network caps apply at schedule/publish.'),
+ ->description('Media to attach. Max 10 per call. Allowed types: image/jpeg, image/png, image/gif, image/webp, video/mp4, video/quicktime, application/pdf. The server per-type size ceilings apply on download; stricter per-network caps apply at schedule/publish.'),
];
}
}
diff --git a/app/Mcp/Tools/Post/CreatePostTool.php b/app/Mcp/Tools/Post/CreatePostTool.php
index da3818c0f..e4574f063 100644
--- a/app/Mcp/Tools/Post/CreatePostTool.php
+++ b/app/Mcp/Tools/Post/CreatePostTool.php
@@ -27,7 +27,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Create one post for one social account in the current workspace: a draft, a post scheduled at a custom time, a post queued in the channel\'s next free slot (queue: next) or first slot (queue: top), a queue post in one specific free slot (queue_slot, an instant from list-free-slots-tool), or a post published now. When the acting member needs approval in this workspace, a scheduled, queued or publish-now post is stored with status pending_approval instead and waits for approve-post-tool. Use create-posts-tool to create a batch. Use list-content-types-tool to discover valid content_types.')]
+#[Description('Create one post for one social account in the current workspace: a draft, a post scheduled at a custom time, a post queued in the channel\'s next free slot (queue: next) or first slot (queue: top), a queue post in one specific free slot (queue_slot, an instant from list-free-slots-tool), or a post published now. When the acting member needs approval in this workspace, a scheduled, queued or publish-now post is stored with status pending_approval instead and waits for approve-post-tool. Use create-posts-tool to create a batch. Use list-content-types-tool to discover valid content_types. To publish a thread on X, Bluesky or Mastodon, put the follow-up posts in meta.thread_replies: up to 24 replies published under the post, each {text, media} with up to 4 media items given by url, id or upload_token, e.g. [{"text": "2/ ..."}, {"text": "3/ ...", "media": [{"url": "https://..."}]}]. Each reply must fit the text limit of the account and follows the media rules of a post on that network. Before a post can be scheduled or published it needs: TikTok meta.privacy_level (get-tiktok-creator-info-tool), Pinterest meta.board_id (list-pinterest-boards-tool), Discord meta.channel_id (list-discord-channels-tool), Google Business events and offers meta.event (title and dates), YouTube a title (meta.title, or the first line of the text); list-content-types-tool lists them per platform as required_meta. A scheduled or published post also needs text or media.')]
class CreatePostTool extends Tool
{
use AuthorizesMcpTool;
@@ -51,11 +51,13 @@ class CreatePostTool extends Tool
->map(fn (SocialAccount $account): Platform => $account->platform)
->values();
+ $validated = HostInlineMedia::forPost($workspace, Post::allowedMediaTypesFor($platforms), $validated);
+
try {
$post = CreatePosts::execute($workspace, $request->user(), [
'status' => $validated['status'] ?? Status::Draft->value,
'content' => $validated['content'] ?? '',
- 'media' => HostInlineMedia::execute($workspace, Post::allowedMediaTypesFor($platforms), $validated['media'] ?? []),
+ 'media' => $validated['media'] ?? [],
'scheduled_at' => $validated['scheduled_at'] ?? $validated['queue_slot'] ?? null,
'queue' => $validated['queue'] ?? null,
'queue_slot' => $validated['queue_slot'] ?? null,
@@ -75,12 +77,12 @@ class CreatePostTool extends Tool
public function schema(JsonSchema $schema): array
{
return [
- 'content' => $schema->string()->description('The post caption/text body. Optional — can be edited later.'),
+ 'content' => $schema->string()->description('The post text, in plain text; use \n for line breaks. When link defusing is on, an X post publishes its links non-clickable (example(.)com); preview-post-tool shows the exact text each network gets. The text must fit the account limit (max_content_length in list-social-accounts-tool; on X, 25000 for an account with long_posts, else 280), Instagram takes at most 5 hashtags, and stories publish no text.'),
'media' => $this->mediaSchema($schema, 'Media for the post.'),
'status' => $schema->string()
->enum([Status::Draft->value, Status::Scheduled->value, Status::Publishing->value])
->description('draft (default) keeps the post editable, scheduled schedules it at scheduled_at or in the queue, publishing publishes it now.'),
- 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future (e.g. 2026-05-10T15:30:00Z), required when status is scheduled without queue.'),
+ 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future and before 2038-01-19, e.g. 2026-05-10T15:30:00Z; without an offset it is read as UTC. Times in responses are UTC (Y-m-d H:i:s). Required when status is scheduled without queue or queue_slot.'),
'queue' => $schema->string()->enum(array_column(QueuePosition::cases(), 'value'))->description(PostStatusRules::QUEUE_DESCRIPTION),
'queue_slot' => $schema->string()->description(PostStatusRules::QUEUE_SLOT_DESCRIPTION),
'label_ids' => $schema->array()
diff --git a/app/Mcp/Tools/Post/CreatePostsTool.php b/app/Mcp/Tools/Post/CreatePostsTool.php
index 7950c1d59..5cc50282e 100644
--- a/app/Mcp/Tools/Post/CreatePostsTool.php
+++ b/app/Mcp/Tools/Post/CreatePostsTool.php
@@ -24,7 +24,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Create one independent post per destination in the current workspace. Each destination may override the shared caption and hosted media.')]
+#[Description('Create one independent post per destination in the current workspace, as the web composer does when several channels are selected: each destination becomes its own post on its own channel, and the posts share a post_group_id. Each destination may override the shared content, media, content_type and meta. status draft keeps them editable, scheduled schedules them at scheduled_at or in each channel queue (queue: next or top), publishing publishes them now; one specific slot (queue_slot) is not taken here, use create-post-tool or move-post-to-slot-tool for that. When the acting member needs approval in this workspace, scheduled, queued and publish-now posts are stored with status pending_approval and wait for approve-post-tool. To publish a thread on X, Bluesky or Mastodon, put the follow-up posts in meta.thread_replies: up to 24 replies published under the post, each {text, media} with up to 4 media items given by url, id or upload_token, e.g. [{"text": "2/ ..."}, {"text": "3/ ...", "media": [{"url": "https://..."}]}]. Each reply must fit the text limit of the account and follows the media rules of a post on that network. Before a post can be scheduled or published it needs: TikTok meta.privacy_level (get-tiktok-creator-info-tool), Pinterest meta.board_id (list-pinterest-boards-tool), Discord meta.channel_id (list-discord-channels-tool), Google Business events and offers meta.event (title and dates), YouTube a title (meta.title, or the first line of the text); list-content-types-tool lists them per platform as required_meta. A scheduled or published post also needs text or media.')]
class CreatePostsTool extends Tool
{
use AuthorizesMcpTool;
@@ -62,17 +62,17 @@ class CreatePostsTool extends Tool
public function schema(JsonSchema $schema): array
{
return [
- 'status' => $schema->string()->enum(['draft', 'scheduled', 'publishing'])->required(),
- 'content' => $schema->string()->description('Shared caption; each destination may override it.'),
+ 'status' => $schema->string()->enum(['draft', 'scheduled', 'publishing'])->required()->description('draft keeps the posts editable, scheduled schedules them at scheduled_at or in the queue, publishing publishes them now.'),
+ 'content' => $schema->string()->description('Shared text; each destination may override it. The post text, in plain text; use \n for line breaks. When link defusing is on, an X post publishes its links non-clickable (example(.)com); preview-post-tool shows the exact text each network gets. The text must fit the account limit (max_content_length in list-social-accounts-tool; on X, 25000 for an account with long_posts, else 280), Instagram takes at most 5 hashtags, and stories publish no text.'),
'media' => $this->mediaSchema($schema, 'Media shared by every destination by default.'),
- 'scheduled_at' => $schema->string()->description('Future ISO 8601 datetime, required when status is scheduled.'),
+ 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future and before 2038-01-19, e.g. 2026-05-10T15:30:00Z; without an offset it is read as UTC. Times in responses are UTC (Y-m-d H:i:s). Required when status is scheduled without queue.'),
'queue' => $schema->string()->enum(array_column(QueuePosition::cases(), 'value'))->description(PostStatusRules::QUEUE_DESCRIPTION),
- 'label_ids' => $schema->array()->items($schema->string()),
+ 'label_ids' => $schema->array()->items($schema->string())->description('Workspace label IDs attached to every post.'),
'destinations' => $schema->array()
->items($schema->object(fn ($destination) => [
- 'social_account_id' => $destination->string()->required(),
+ 'social_account_id' => $destination->string()->required()->description('UUID of the connected social account (list-social-accounts-tool).'),
'content_type' => $destination->string()->description('Format for this destination. Optional. Omitted, it is chosen as the web composer does: on pinterest a video makes pinterest_video_pin, several images pinterest_carousel, else pinterest_pin; on tiktok images only make tiktok_photo, else tiktok_video; every other network takes its default_content_type (list-content-types-tool). A type sent explicitly is validated against the media and refused when they do not match.'),
- 'content' => $destination->string()->description('Caption override.'),
+ 'content' => $destination->string()->description('Text override for this destination, with the same rules as the shared content.'),
'media' => $this->mediaSchema($schema, 'Media override for this destination; same item shape as the shared media.'),
'meta' => $destination->object()->description(PostPlatformMetaRules::documentation()),
]))
diff --git a/app/Mcp/Tools/Post/DeletePostTool.php b/app/Mcp/Tools/Post/DeletePostTool.php
index 61f06b608..299f516ec 100644
--- a/app/Mcp/Tools/Post/DeletePostTool.php
+++ b/app/Mcp/Tools/Post/DeletePostTool.php
@@ -16,7 +16,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
#[IsDestructive]
-#[Description('Delete a post permanently. This cannot be undone.')]
+#[Description('Delete a post from TryPost permanently; this cannot be undone. A post is never removed from the network where it was published. Posts that are publishing, published, partially_published or failed cannot be changed or deleted. A member who needs approval may delete only posts they wrote, or requests they made that are still pending approval.')]
class DeletePostTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/GetPostTool.php b/app/Mcp/Tools/Post/GetPostTool.php
index da8c70c42..ba3790941 100644
--- a/app/Mcp/Tools/Post/GetPostTool.php
+++ b/app/Mcp/Tools/Post/GetPostTool.php
@@ -17,7 +17,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('Get a specific post by ID with all its platform content and labels.')]
+#[Description('Get a specific post by ID. Times are UTC (Y-m-d H:i:s). Returns its content, media, labels, status, schedule_mode, scheduled_at, published_at, recurrence, approval fields (approval_requested_by, approved_by and their times), origin, post_group_id, and for its platform the content_type, meta (thread_replies included), status, error_message and platform_url.')]
class GetPostTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/PreviewPostTool.php b/app/Mcp/Tools/Post/PreviewPostTool.php
index 31e472206..92f098745 100644
--- a/app/Mcp/Tools/Post/PreviewPostTool.php
+++ b/app/Mcp/Tools/Post/PreviewPostTool.php
@@ -16,7 +16,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('Preview how a post will render on each enabled platform — applies platform-specific content sanitization (length truncation, forbidden chars, etc.) without publishing. Returns the original content alongside per-platform sanitized versions and length stats.')]
+#[Description('Preview how a post will be sent to each enabled platform without publishing: the exact text each network gets (X links defused when that is on), next to the original content, with length stats. Use it to check a text before scheduling.')]
class PreviewPostTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/PublishPostTool.php b/app/Mcp/Tools/Post/PublishPostTool.php
index 5a7fe3a1f..b5261aa70 100644
--- a/app/Mcp/Tools/Post/PublishPostTool.php
+++ b/app/Mcp/Tools/Post/PublishPostTool.php
@@ -23,7 +23,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsDestructive;
#[IsDestructive]
-#[Description('Publish a draft post on its social account — immediately, at a future time (scheduled_at) or in the channel queue (queue). Use update-post-tool first to change its content, content_type or meta. Before publishing, the attached media is validated against the post\'s content_type (file size, video duration, GIF, MOV — see list-content-types-tool); a cap violation returns a per-platform error and nothing is published. When the acting member needs approval in this workspace, the post is stored with status pending_approval instead and waits for approve-post-tool.')]
+#[Description('Publish a post now, schedule it at a custom time (scheduled_at) or put it in the channel queue (queue). Works on drafts and on scheduled posts. Use update-post-tool first to change its content, content_type or meta. It is validated like a scheduled post: text limits, required meta, the media rules of its content_type (see list-content-types-tool) and thread replies; a failure names the platform and field, and nothing is published. Posts that are publishing, published, partially_published or failed cannot be changed or deleted. When the acting member needs approval in this workspace, the post is stored with status pending_approval instead and waits for approve-post-tool. Before a post can be scheduled or published it needs: TikTok meta.privacy_level (get-tiktok-creator-info-tool), Pinterest meta.board_id (list-pinterest-boards-tool), Discord meta.channel_id (list-discord-channels-tool), Google Business events and offers meta.event (title and dates), YouTube a title (meta.title, or the first line of the text); list-content-types-tool lists them per platform as required_meta. A scheduled or published post also needs text or media.')]
class PublishPostTool extends Tool
{
use AuthorizesMcpTool;
@@ -83,7 +83,7 @@ class PublishPostTool extends Tool
return [
'post_id' => $schema->string()->required()->description('UUID of the post to publish.'),
'queue' => $schema->string()->enum(array_column(QueuePosition::cases(), 'value'))->description(PostStatusRules::QUEUE_DESCRIPTION),
- 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future. If provided, the post is queued for that time. If omitted, publishing starts immediately.'),
+ 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future and before 2038-01-19, e.g. 2026-05-10T15:30:00Z; without an offset it is read as UTC. Times in responses are UTC (Y-m-d H:i:s). If provided, the post is scheduled at that custom time. If omitted, publishing starts immediately.'),
];
}
}
diff --git a/app/Mcp/Tools/Post/RequestMediaUploadTool.php b/app/Mcp/Tools/Post/RequestMediaUploadTool.php
index 24a73fa3a..5b5a42b8e 100644
--- a/app/Mcp/Tools/Post/RequestMediaUploadTool.php
+++ b/app/Mcp/Tools/Post/RequestMediaUploadTool.php
@@ -17,7 +17,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Issue a one-shot signed POST URL that lets the user upload a local file (image, video, or PDF document) directly to this workspace. Accepted types: JPEG, PNG, GIF, WebP, MP4, MOV, PDF, plus HEIC/HEIF photos (converted to JPEG) when the server can convert them. Returns an upload_token, upload_url, max_bytes, and max_bytes_by_type — those are the workspace-wide ceilings (max_bytes equals the video cap); each network enforces its own, usually smaller, size / duration / format caps at schedule or publish time, so check list-content-types-tool for the post\'s enabled content_types first. Video duration is measured on the server after the upload. Upload the file with one multipart/form-data POST to upload_url, the file in the form field named by field_name (`media`), e.g. `curl -F media=@path/to/file "<upload_url>"`; hand that command to the user or run it from the MCP client. The URL works once, until expires_at; ask for a new one for each file. A refused file answers 422 with the reason. The upload is kept 24 hours (unused uploads are then deleted). After upload, pass the upload_token as a media item to create-post-tool, create-posts-tool or update-post-tool, or call attach-media-from-upload-tool(post_id, upload_token), before it expires. A token is spent by the first post that takes it; to put the same file on another post, pass that post\'s media id instead. A file already online can skip the upload: pass its url as a media item or call attach-media-from-url-tool.')]
+#[Description('Issue a one-shot signed POST URL that lets the user upload a local file (image, video, or PDF document) directly to this workspace. Accepted types: JPEG, PNG, GIF, WebP, MP4, MOV, PDF, plus HEIC/HEIF photos (converted to JPEG) when the server can convert them. Returns an upload_token, upload_url, max_bytes, and max_bytes_by_type — those are the server ceilings (max_bytes equals the video cap; an image is also refused above 67 megapixels by default); each network enforces its own, usually smaller, size / duration / format caps at schedule or publish time, so check list-content-types-tool for the post\'s enabled content_types first. Video duration is measured on the server after the upload. Upload the file with one multipart/form-data POST to upload_url, the file in the form field named by field_name (`media`), e.g. `curl -F media=@path/to/file "<upload_url>"`; hand that command to the user or run it from the MCP client. The URL works once, until expires_at; ask for a new one for each file. A refused file answers 422 with the reason. The upload is kept 24 hours (unused uploads are then deleted). After upload, pass the upload_token as a media item to create-post-tool, create-posts-tool or update-post-tool, or call attach-media-from-upload-tool(post_id, upload_token), before it expires. A token is spent by the first post that takes it; to put the same file on another post, pass that post\'s media id instead. A file already online can skip the upload: pass its url as a media item or call attach-media-from-url-tool.')]
class RequestMediaUploadTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/SetPostRecurrenceTool.php b/app/Mcp/Tools/Post/SetPostRecurrenceTool.php
index c52da94f6..3e8e2bd8d 100644
--- a/app/Mcp/Tools/Post/SetPostRecurrenceTool.php
+++ b/app/Mcp/Tools/Post/SetPostRecurrenceTool.php
@@ -26,7 +26,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Make a scheduled post repeat: every `interval` days, weeks, months or years, `times` more times. The post must be scheduled with a time, and the last occurrence must fall before the application horizon. Only members who publish directly can set a recurrence.')]
+#[Description('Make a scheduled post repeat: every `interval` days, weeks, months or years, `times` more times. The post must be scheduled with a time, and the last occurrence must fall on or before 2037-12-31 23:59:59 UTC. Each occurrence keeps the same local time in the channel time zone. Only members who publish directly can set a recurrence.')]
class SetPostRecurrenceTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/UpdatePostTool.php b/app/Mcp/Tools/Post/UpdatePostTool.php
index c4d647f64..47c37d108 100644
--- a/app/Mcp/Tools/Post/UpdatePostTool.php
+++ b/app/Mcp/Tools/Post/UpdatePostTool.php
@@ -27,7 +27,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Update one post for its existing social account. Caption, media, content_type, meta (platform settings, merged with the stored ones), status, schedule, queue and labels may change; content_type and meta are top-level fields because a post has exactly one social account, which is fixed. When the acting member needs approval in this workspace, a scheduled, queued or publish-now update is stored with status pending_approval instead.')]
+#[Description('Update one post for its existing social account. Caption, media, content_type, meta (platform settings, merged with the stored ones), status, schedule, queue and labels may change; content_type and meta are top-level fields because a post has exactly one social account, which is fixed. When the acting member needs approval in this workspace, a scheduled, queued or publish-now update is stored with status pending_approval instead. meta is merged with the stored settings: send null for a key to clear it; thread_replies replaces the whole list. To place the post in one specific free slot use move-post-to-slot-tool. Posts that are publishing, published, partially_published or failed cannot be changed or deleted. To publish a thread on X, Bluesky or Mastodon, put the follow-up posts in meta.thread_replies: up to 24 replies published under the post, each {text, media} with up to 4 media items given by url, id or upload_token, e.g. [{"text": "2/ ..."}, {"text": "3/ ...", "media": [{"url": "https://..."}]}]. Each reply must fit the text limit of the account and follows the media rules of a post on that network. Before a post can be scheduled or published it needs: TikTok meta.privacy_level (get-tiktok-creator-info-tool), Pinterest meta.board_id (list-pinterest-boards-tool), Discord meta.channel_id (list-discord-channels-tool), Google Business events and offers meta.event (title and dates), YouTube a title (meta.title, or the first line of the text); list-content-types-tool lists them per platform as required_meta. A scheduled or published post also needs text or media.')]
class UpdatePostTool extends Tool
{
use AuthorizesMcpTool;
@@ -56,9 +56,7 @@ class UpdatePostTool extends Tool
->after(fn (ValidatorContract $validator) => PostRequestRules::afterUpdate($validator, $post, $input))
->validate();
- if (array_key_exists('media', $validated)) {
- $validated['media'] = HostInlineMedia::execute($workspace, $post->allowedMediaTypes(), $validated['media']);
- }
+ $validated = HostInlineMedia::forPost($workspace, $post->allowedMediaTypes(), $validated);
try {
$result = UpdatePost::execute($workspace, $post, $validated, $request->user());
@@ -81,9 +79,9 @@ class UpdatePostTool extends Tool
{
return [
'post_id' => $schema->string()->required()->description('UUID of the post to update.'),
- 'content' => $schema->string()->description('New caption/text body.'),
+ 'content' => $schema->string()->description('The post text, in plain text; use \n for line breaks. When link defusing is on, an X post publishes its links non-clickable (example(.)com); preview-post-tool shows the exact text each network gets. The text must fit the account limit (max_content_length in list-social-accounts-tool; on X, 25000 for an account with long_posts, else 280), Instagram takes at most 5 hashtags, and stories publish no text.'),
'media' => $this->mediaSchema($schema, 'Replaces the post media; omit to keep the current media.'),
- 'scheduled_at' => $schema->string()->description('Future ISO 8601 datetime. Required for status "scheduled" unless the post already has a future schedule.'),
+ 'scheduled_at' => $schema->string()->description('ISO 8601 datetime in the future and before 2038-01-19, e.g. 2026-05-10T15:30:00Z; without an offset it is read as UTC. Times in responses are UTC (Y-m-d H:i:s). Required for status scheduled unless the post already has a future schedule or queue is sent.'),
'queue' => $schema->string()->enum(array_column(QueuePosition::cases(), 'value'))->description(PostStatusRules::QUEUE_DESCRIPTION),
'status' => $schema->string()
->enum([Status::Draft->value, Status::Scheduled->value, Status::Publishing->value])
diff --git a/app/Mcp/Tools/Repurpose/CreateRepurposeTool.php b/app/Mcp/Tools/Repurpose/CreateRepurposeTool.php
index c3a66fb09..2b7eb8fe9 100644
--- a/app/Mcp/Tools/Repurpose/CreateRepurposeTool.php
+++ b/app/Mcp/Tools/Repurpose/CreateRepurposeTool.php
@@ -5,10 +5,13 @@ declare(strict_types=1);
namespace App\Mcp\Tools\Repurpose;
use App\Actions\Repurpose\CreateRepurpose;
+use App\Enums\Repurpose\PublishMode;
+use App\Enums\Repurpose\SourceFormat;
use App\Http\Resources\Api\RepurposeResource;
use App\Mcp\Concerns\AuthorizesMcpTool;
use App\Models\Repurpose;
use App\Models\Workspace;
+use App\Support\PostPlatformMetaRules;
use App\Support\Requests\Repurpose\RepurposeRequestRules;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Illuminate\Validation\ValidationException;
@@ -18,7 +21,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Create a repurpose. It starts as a draft and only replicates videos published after it is activated. Source must be an Instagram or Facebook account, the only networks that allow downloading the video. Each destination picks the format it publishes as, so a Story can land as a Reel. Google Business cannot be a destination.')]
+#[Description('Create a repurpose. It starts as a draft and only replicates videos published after it is activated. Source must be an Instagram or Facebook account, the only networks that allow downloading the video. Each destination picks the format it publishes as, so a Story can land as a Reel. Google Business cannot be a destination. Required meta (TikTok privacy_level, Pinterest board_id, Discord channel_id) is checked when the repurpose is activated and on every update of an active one. A source account can back one repurpose per source_format and cannot also be a destination.')]
class CreateRepurposeTool extends Tool
{
use AuthorizesMcpTool;
@@ -49,9 +52,15 @@ class CreateRepurposeTool extends Tool
{
return [
'source_social_account_id' => $schema->string()->required()->description('Instagram or Facebook account to watch.'),
- 'source_format' => $schema->string()->description('Which video format to watch: reel, video or story. Defaults to reel.'),
- 'publish_mode' => $schema->string()->description('publish to schedule each replicated video straight away, or draft to leave it in TryPost for review. Defaults to publish.'),
- 'destinations' => $schema->array()->description('Accounts to republish to, each with a content_type that accepts video and optional per-platform meta. Google Business accounts are rejected.'),
+ 'source_format' => $schema->string()->enum(array_column(SourceFormat::cases(), 'value'))->description('Which video format to watch: reel, video or story. Defaults to reel.'),
+ 'publish_mode' => $schema->string()->enum(array_column(PublishMode::cases(), 'value'))->description('publish to schedule each replicated video straight away, or draft to leave it in TryPost for review. Defaults to publish.'),
+ 'destinations' => $schema->array()
+ ->items($schema->object(fn (JsonSchema $destination): array => [
+ 'social_account_id' => $destination->string()->required()->description('UUID of a connected account of this workspace (not Google Business, not the source account).'),
+ 'content_type' => $destination->string()->required()->description('A content type of that account that accepts video (list-content-types-tool).'),
+ 'meta' => $destination->object()->description(PostPlatformMetaRules::documentation().' In a repurpose, thread reply media are given by media id only.'),
+ ]))
+ ->description('Accounts to republish to. Google Business accounts are rejected.'),
];
}
}
diff --git a/app/Mcp/Tools/Repurpose/UpdateRepurposeTool.php b/app/Mcp/Tools/Repurpose/UpdateRepurposeTool.php
index 43b23df43..de1d8ba51 100644
--- a/app/Mcp/Tools/Repurpose/UpdateRepurposeTool.php
+++ b/app/Mcp/Tools/Repurpose/UpdateRepurposeTool.php
@@ -5,12 +5,15 @@ declare(strict_types=1);
namespace App\Mcp\Tools\Repurpose;
use App\Actions\Repurpose\UpdateRepurpose;
+use App\Enums\Repurpose\PublishMode;
+use App\Enums\Repurpose\SourceFormat;
use App\Http\Resources\Api\RepurposeResource;
use App\Mcp\Concerns\AuthorizesMcpTool;
use App\Mcp\Concerns\ResolvesWorkspaceRepurpose;
use App\Mcp\Requests\Repurpose\RepurposeIdRequest;
use App\Models\Repurpose;
use App\Models\Workspace;
+use App\Support\PostPlatformMetaRules;
use App\Support\Requests\Repurpose\RepurposeRequestRules;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
@@ -19,7 +22,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Update a repurpose. Changing the source account or the watched format resets the watermark, so only videos published after the change are replicated.')]
+#[Description('Update a repurpose. Changing the source account or the watched format resets the watermark, so only videos published after the change are replicated. Required meta (TikTok privacy_level, Pinterest board_id, Discord channel_id) is checked when the repurpose is activated and on every update of an active one. A source account can back one repurpose per source_format and cannot also be a destination.')]
class UpdateRepurposeTool extends Tool
{
use AuthorizesMcpTool, ResolvesWorkspaceRepurpose;
@@ -58,9 +61,15 @@ class UpdateRepurposeTool extends Tool
return [
'repurpose_id' => $schema->string()->required()->description('The repurpose to update.'),
'source_social_account_id' => $schema->string()->description('Move the repurpose to another source account.'),
- 'source_format' => $schema->string()->description('Which video format to watch: reel, video or story.'),
- 'publish_mode' => $schema->string()->description('publish to schedule each replicated video straight away, or draft to leave it in TryPost for review.'),
- 'destinations' => $schema->array()->description('Replaces the destination list.'),
+ 'source_format' => $schema->string()->enum(array_column(SourceFormat::cases(), 'value'))->description('Which video format to watch: reel, video or story.'),
+ 'publish_mode' => $schema->string()->enum(array_column(PublishMode::cases(), 'value'))->description('publish to schedule each replicated video straight away, or draft to leave it in TryPost for review.'),
+ 'destinations' => $schema->array()
+ ->items($schema->object(fn (JsonSchema $destination): array => [
+ 'social_account_id' => $destination->string()->required()->description('UUID of a connected account of this workspace (not Google Business, not the source account).'),
+ 'content_type' => $destination->string()->required()->description('A content type of that account that accepts video (list-content-types-tool).'),
+ 'meta' => $destination->object()->description(PostPlatformMetaRules::documentation().' In a repurpose, thread reply media are given by media id only.'),
+ ]))
+ ->description('Replaces the destination list.'),
];
}
}
diff --git a/app/Mcp/Tools/Signature/CreateSignatureTool.php b/app/Mcp/Tools/Signature/CreateSignatureTool.php
index 70b612377..1d2df32ac 100644
--- a/app/Mcp/Tools/Signature/CreateSignatureTool.php
+++ b/app/Mcp/Tools/Signature/CreateSignatureTool.php
@@ -16,7 +16,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Create a new signature with a name and content (hashtags, links, custom text, etc.).')]
+#[Description('Create a new signature with a name and content (hashtags, links, custom text, etc.). A signature is not added automatically to any post: append its content to the post content yourself.')]
class CreateSignatureTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Signature/ListSignaturesTool.php b/app/Mcp/Tools/Signature/ListSignaturesTool.php
index 7ca8a8382..dbaed7559 100644
--- a/app/Mcp/Tools/Signature/ListSignaturesTool.php
+++ b/app/Mcp/Tools/Signature/ListSignaturesTool.php
@@ -17,7 +17,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('List the signatures for the current workspace. Signatures are reusable text blocks (hashtags, links, custom text) that can be appended to posts. Paginated with the app page size: pass page; the response carries total, per_page, current_page and last_page.')]
+#[Description('List the signatures for the current workspace. Signatures are reusable text blocks (hashtags, links, custom text) that you can append to a post content; a signature is not added automatically to any post. Paginated with the app page size: pass page; the response carries total, per_page, current_page and last_page.')]
class ListSignaturesTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/SocialAccount/GeneratePostingScheduleTool.php b/app/Mcp/Tools/SocialAccount/GeneratePostingScheduleTool.php
index 09abb1447..57fbc1a57 100644
--- a/app/Mcp/Tools/SocialAccount/GeneratePostingScheduleTool.php
+++ b/app/Mcp/Tools/SocialAccount/GeneratePostingScheduleTool.php
@@ -58,7 +58,7 @@ class GeneratePostingScheduleTool extends Tool
return [
'account_id' => $schema->string()->required()->description('The UUID of the connected social account.'),
'mode' => $schema->string()->enum(['goal', 'recommended'])->required()->description('goal or recommended; accepted for parity, both generate from the goal.'),
- 'goal' => $schema->integer()->nullable()->description('Posts per week; defaults to the channel goal, else 3.'),
+ 'goal' => $schema->integer()->nullable()->description('Posts per week, 1 to 28; defaults to the channel goal, else 3.'),
];
}
}
diff --git a/app/Mcp/Tools/SocialAccount/GetTikTokCreatorInfoTool.php b/app/Mcp/Tools/SocialAccount/GetTikTokCreatorInfoTool.php
index b3a35a7ac..9e81cc655 100644
--- a/app/Mcp/Tools/SocialAccount/GetTikTokCreatorInfoTool.php
+++ b/app/Mcp/Tools/SocialAccount/GetTikTokCreatorInfoTool.php
@@ -22,7 +22,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
#[Name('get-tiktok-creator-info-tool')]
-#[Description('Read what TikTok lets a connected TikTok account publish right now: privacy_level_options (the only privacy_level values allowed for this creator), comment_disabled / duet_disabled / stitch_disabled (when true, allow_comments / allow_duet / allow_stitch must stay false), max_video_post_duration_sec, and can_post. Call it before creating or scheduling a TikTok post and pick platforms[].meta.privacy_level from privacy_level_options. can_post false means TikTok banned this creator from posting. When TikTok reports a posting limit (daily cap, quota or rate limit) the tool returns an error instead: scheduled posts retry automatically once it lifts. If TikTok does not answer, the tool returns an error: retry in a moment.')]
+#[Description('Read what TikTok lets a connected TikTok account publish right now: privacy_level_options (the only privacy_level values allowed for this creator), comment_disabled / duet_disabled / stitch_disabled (when true, allow_comments / allow_duet / allow_stitch must stay false), max_video_post_duration_sec (the longest video TikTok accepts from this creator; it is not checked when you schedule, so compare the video duration yourself), and can_post. Call it before creating or scheduling a TikTok post and pick platforms[].meta.privacy_level from privacy_level_options. can_post false means TikTok banned this creator from posting. When TikTok reports a posting limit (daily cap, quota or rate limit) the tool returns an error instead: scheduled posts retry automatically once it lifts. If TikTok does not answer, the tool returns an error: retry in a moment.')]
class GetTikTokCreatorInfoTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/SocialAccount/ListFreeSlotsTool.php b/app/Mcp/Tools/SocialAccount/ListFreeSlotsTool.php
index 63bfaee69..04329eac8 100644
--- a/app/Mcp/Tools/SocialAccount/ListFreeSlotsTool.php
+++ b/app/Mcp/Tools/SocialAccount/ListFreeSlotsTool.php
@@ -18,7 +18,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('List the next free queue slots of a channel as UTC instants, soonest first. A slot is free when no scheduled post and no queue request pending approval holds it.')]
+#[Description('List the next free queue slots of a channel as UTC instants, soonest first: at most 30, within the next 90 days. A slot is free when no scheduled post and no queue request pending approval holds it. Pass one as queue_slot to create-post-tool, or use move-post-to-slot-tool for an existing post.')]
class ListFreeSlotsTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/SocialAccount/ListSocialAccountsTool.php b/app/Mcp/Tools/SocialAccount/ListSocialAccountsTool.php
index e67f67c88..4968937dc 100644
--- a/app/Mcp/Tools/SocialAccount/ListSocialAccountsTool.php
+++ b/app/Mcp/Tools/SocialAccount/ListSocialAccountsTool.php
@@ -16,7 +16,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('List the connected social accounts for the current workspace (LinkedIn, X, Bluesky, Pinterest, Threads, etc.). Each account has an id, platform, display_name, username, connection status, and has_posting_schedule (true when the account has posting times, so posts can use queue). Paginated with the app page size: pass page; the response carries total, per_page, current_page and last_page.')]
+#[Description('List the connected social accounts for the current workspace (LinkedIn, X, Bluesky, Pinterest, Threads, etc.). Each account has an id, platform, display_name, username, connection status (connected, token_expired or disconnected), timezone (the channel time zone: posting times and queue slots are in it), posting_goal (posts per week, or null), has_posting_schedule (true when the account has posting times, so posts can use queue) max_content_length (the text limit of this account), long_posts and verified_badge. On X, long_posts is true for an account with a paid X subscription (Basic, Premium or Premium+) or a verified organization, and it may post up to 25000 characters; every other X account is limited to 280. verified_badge is the checkmark X shows (blue, business or government, else null); a badge alone does not mean long posts, so read long_posts or max_content_length. Both are refreshed when the account connects and once a day. Paginated with the app page size: pass page; the response carries total, per_page, current_page and last_page.')]
class ListSocialAccountsTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/SocialAccount/ReorderQueueTool.php b/app/Mcp/Tools/SocialAccount/ReorderQueueTool.php
index 4780c9c4c..1f009d855 100644
--- a/app/Mcp/Tools/SocialAccount/ReorderQueueTool.php
+++ b/app/Mcp/Tools/SocialAccount/ReorderQueueTool.php
@@ -53,7 +53,7 @@ class ReorderQueueTool extends Tool
{
return [
'account_id' => $schema->string()->required()->description('The UUID of the connected social account.'),
- 'post_ids' => $schema->array()->items($schema->string())->required()->description('UUIDs of the first queued posts of the channel, in the new order.'),
+ 'post_ids' => $schema->array()->items($schema->string())->required()->description('UUIDs of the first queued posts of the channel, in the new order (at most 500).'),
];
}
}
diff --git a/app/Mcp/Tools/SocialAccount/UpdatePostingScheduleTool.php b/app/Mcp/Tools/SocialAccount/UpdatePostingScheduleTool.php
index e3b6b060d..b6231889d 100644
--- a/app/Mcp/Tools/SocialAccount/UpdatePostingScheduleTool.php
+++ b/app/Mcp/Tools/SocialAccount/UpdatePostingScheduleTool.php
@@ -20,7 +20,7 @@ use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
-#[Description('Replace the posting schedule of a channel: time zone, weekly posting goal and the seven days (day 0 is Sunday) with their local HH:mm posting times. A null posting_schedule clears it. Queued posts whose slot no longer exists are re-placed into the first free slots, and a time zone change moves every queued post to the same local clock time in the new zone. Only workspace admins can edit it.')]
+#[Description('Replace the posting schedule of a channel: time zone, weekly posting goal and the seven days (day 0 is Sunday) with their posting times: at most 4 unique HH:mm times per day, in the channel time zone. A null posting_schedule clears it. Queued posts whose slot no longer exists are re-placed into the first free slots, and a time zone change moves every queued post to the same local clock time in the new zone. Only workspace admins can edit it.')]
class UpdatePostingScheduleTool extends Tool
{
use AuthorizesMcpTool;
@@ -77,11 +77,11 @@ class UpdatePostingScheduleTool extends Tool
return [
'account_id' => $schema->string()->required()->description('The UUID of the connected social account.'),
'timezone' => $schema->string()->required()->description('IANA time zone of the channel, e.g. America/Sao_Paulo.'),
- 'posting_goal' => $schema->integer()->nullable()->description('Weekly posting goal.'),
+ 'posting_goal' => $schema->integer()->nullable()->description('Weekly posting goal, 1 to 28 posts, or null.'),
'posting_schedule' => $schema->array()->nullable()->items($schema->object([
'day' => $schema->integer()->required()->description('0 (Sunday) to 6 (Saturday).'),
'enabled' => $schema->boolean()->required(),
- 'times' => $schema->array()->items($schema->string())->required()->description('Local HH:mm times of that day.'),
+ 'times' => $schema->array()->items($schema->string())->required()->description('At most 4 unique HH:mm times of that day, in the channel time zone.'),
]))->description('Exactly seven days, or null to clear the schedule.'),
];
}
diff --git a/app/Mcp/Tools/Webhook/CreateWebhookTool.php b/app/Mcp/Tools/Webhook/CreateWebhookTool.php
index 2a3425209..536143407 100644
--- a/app/Mcp/Tools/Webhook/CreateWebhookTool.php
+++ b/app/Mcp/Tools/Webhook/CreateWebhookTool.php
@@ -20,7 +20,7 @@ use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Tool;
use RuntimeException;
-#[Description('Create an outgoing webhook for the current workspace. Returns the signing secret — it can be read later with get-webhook-tool or rotated with rotate-webhook-secret-tool. Private or local endpoints are rejected. Creating does not send a test request.')]
+#[Description('Create an outgoing webhook for the current workspace. Returns the signing secret — it can be read later with get-webhook-tool or rotated with rotate-webhook-secret-tool. Private or local endpoints are rejected. Creating does not send a test request. Each delivery is a JSON POST signed in the X-Webhook-Signature header (HMAC-SHA256 of the body with the signing secret). After 5 failed deliveries in a row the webhook is paused and the account owner is emailed.')]
class CreateWebhookTool extends Tool
{
use AuthorizesMcpTool;
@@ -54,7 +54,7 @@ class CreateWebhookTool extends Tool
public function schema(JsonSchema $schema): array
{
return [
- 'endpoint' => $schema->string()->required()->description('Public URL that will receive signed webhook payloads. Private or local addresses are rejected.'),
+ 'endpoint' => $schema->string()->required()->description('Public URL, up to 255 characters, that will receive signed webhook payloads. Private or local addresses are rejected.'),
'events' => $schema->array()
->items($schema->string()->enum(array_column(EventType::cases(), 'value')))
->required()
diff --git a/app/Mcp/Tools/Workspace/GetWorkspaceTool.php b/app/Mcp/Tools/Workspace/GetWorkspaceTool.php
index dd4d95959..fad9b6485 100644
--- a/app/Mcp/Tools/Workspace/GetWorkspaceTool.php
+++ b/app/Mcp/Tools/Workspace/GetWorkspaceTool.php
@@ -15,7 +15,7 @@ use Laravel\Mcp\Server\Tool;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly]
-#[Description('Get the current workspace details (id, name, timestamps).')]
+#[Description('Get the current workspace (the one this connection acts in: id, name, timestamps) and what the caller may do there: me.is_admin (manages members, settings, channels and posting times), me.requires_approval (true when the caller\'s scheduled, queued and publish-now posts are stored as pending_approval until an approver uses approve-post-tool) and me.publishes_directly.')]
class GetWorkspaceTool extends Tool
{
use AuthorizesMcpTool;
@@ -28,6 +28,6 @@ class GetWorkspaceTool extends Tool
return $workspace;
}
- return Response::structured((new WorkspaceResource($workspace))->resolve());
+ return Response::structured((new WorkspaceResource($workspace))->for($request->user())->resolve());
}
}
diff --git a/app/Services/RssFeed/RssFeedItemNormalizer.php b/app/Services/RssFeed/RssFeedItemNormalizer.php
index 4799638c3..ff20ff1db 100644
--- a/app/Services/RssFeed/RssFeedItemNormalizer.php
+++ b/app/Services/RssFeed/RssFeedItemNormalizer.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Services\RssFeed;
use Carbon\CarbonImmutable;
+use Illuminate\Support\Str;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler\UriResolver;
use Throwable;
@@ -30,10 +31,10 @@ final class RssFeedItemNormalizer
$html = $this->nonEmpty(data_get($raw, 'html'));
$excerpt = $html !== null
? $this->textFromHtml($html)
- : $this->collapse((string) data_get($raw, 'text', ''));
+ : Str::squish((string) data_get($raw, 'text', ''));
$excerpt = $excerpt === '' ? null : $this->truncate($excerpt, self::MAX_EXCERPT_LENGTH, '…');
- $title = $this->collapse($this->decode(strip_tags((string) data_get($raw, 'title', ''))));
+ $title = Str::squish($this->decode(strip_tags((string) data_get($raw, 'title', ''))));
if ($title === '' && $excerpt !== null) {
$title = rtrim(mb_substr($excerpt, 0, self::FALLBACK_TITLE_LENGTH));
@@ -47,7 +48,7 @@ final class RssFeedItemNormalizer
$title = (string) $url;
}
- $author = $this->collapse($this->decode(strip_tags((string) data_get($raw, 'author', ''))));
+ $author = Str::squish($this->decode(strip_tags((string) data_get($raw, 'author', ''))));
return new ParsedRssFeedItem(
guid: $this->nonEmpty(data_get($raw, 'guid')) ?? $url,
@@ -62,7 +63,7 @@ final class RssFeedItemNormalizer
public function feedTitle(?string $title, string $baseUrl): string
{
- $title = $this->collapse($this->decode(strip_tags((string) $title)));
+ $title = Str::squish($this->decode(strip_tags((string) $title)));
if ($title === '') {
$title = (string) parse_url($baseUrl, PHP_URL_HOST);
@@ -153,7 +154,7 @@ final class RssFeedItemNormalizer
$html = (string) preg_replace('~<(script|style)\b[^>]*>.*?</\1>~is', ' ', $html);
$html = (string) preg_replace(self::BLOCK_TAGS, ' ', $html);
- return $this->collapse($this->decode(strip_tags($html)));
+ return Str::squish($this->decode(strip_tags($html)));
}
private function decode(string $value): string
@@ -161,11 +162,6 @@ final class RssFeedItemNormalizer
return html_entity_decode($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
}
- private function collapse(string $value): string
- {
- return trim((string) preg_replace('/[\s\x{00A0}]+/u', ' ', $value));
- }
-
private function truncate(string $value, int $limit, string $end): string
{
if (mb_strlen($value) <= $limit) {
diff --git a/app/Services/Social/ContentSanitizer.php b/app/Services/Social/ContentSanitizer.php
index d5d303bcd..6b1c61f5d 100644
--- a/app/Services/Social/ContentSanitizer.php
+++ b/app/Services/Social/ContentSanitizer.php
@@ -23,8 +23,16 @@ class ContentSanitizer
*/
private const LINK_PATTERN = '~(^|[^\p{L}\p{N}\p{M}_@/.])((?:https?://(?:[^\s/@]+@)?)?(?:www\.)?)((?:[\p{L}\p{N}](?:[\p{L}\p{N}\p{M}-]*[\p{L}\p{N}\p{M}])?\.)+([\p{L}\p{N}\p{M}-]{2,63}))(?![\p{L}\p{N}\p{M}-])((?:/\S*)?)~iu';
+ private const TAG_BODY = '/?[a-z][^<>]*>';
+
+ private const TAG_PATTERN = '~<'.self::TAG_BODY.'~i';
+
+ private const TYPED_BRACKET_PATTERN = '~<(?!'.self::TAG_BODY.')~i';
+
public function sanitize(string $content, Platform $platform): string
{
+ $content = $this->escapeTypedBrackets($content);
+
return match ($platform) {
Platform::LinkedIn, Platform::LinkedInPage => $this->convertBoldAndStrip($content),
Platform::Mastodon => $this->stripUnsafeHtml($content),
@@ -53,7 +61,7 @@ class ContentSanitizer
return match ($platform) {
Platform::Telegram => html_entity_decode(strip_tags($sanitized), ENT_QUOTES | ENT_HTML5, 'UTF-8'),
- Platform::Mastodon => strip_tags($sanitized),
+ Platform::Mastodon => preg_replace(self::TAG_PATTERN, '', $sanitized) ?? $sanitized,
default => $sanitized,
};
}
@@ -63,7 +71,18 @@ class ContentSanitizer
*/
public function plainText(string $content): string
{
- return $this->stripHtml($content);
+ return $this->stripHtml($this->escapeTypedBrackets($content));
+ }
+
+ /**
+ * The composer stores plain text, so a `<` that does not open a tag is
+ * something the person typed (`I <3 TryPost`, `price < 10`). It becomes
+ * `&lt;`, or stripping tags would drop everything after it. Tags, from the
+ * former rich editor in older posts or typed, are still removed.
+ */
+ private function escapeTypedBrackets(string $content): string
+ {
+ return preg_replace(self::TYPED_BRACKET_PATTERN, '&lt;', $content) ?? $content;
}
/**
@@ -106,12 +125,7 @@ class ContentSanitizer
*/
private function toTelegramHtml(string $content): string
{
- // Block elements → newlines (Telegram HTML has no <p>/<br>/<li>).
- $content = preg_replace('/<p[^>]*>/i', '', $content);
- $content = str_replace('</p>', "\n", $content);
- $content = preg_replace('/<br\s*\/?>/i', "\n", $content);
- $content = preg_replace('/<li[^>]*>/i', '- ', $content);
- $content = str_replace('</li>', "\n", $content);
+ $content = $this->blocksToLines($content);
// Normalize to Telegram's tag names, then keep only its allowlist.
$content = preg_replace(['/<(\/?)strong>/i', '/<(\/?)em>/i'], ['<$1b>', '<$1i>'], $content);
@@ -130,16 +144,7 @@ class ContentSanitizer
private function stripHtml(string $content): string
{
- // Convert <p> tags to newlines
- $content = preg_replace('/<p[^>]*>/i', '', $content);
- $content = str_replace('</p>', "\n", $content);
-
- // Convert <br> to newlines
- $content = preg_replace('/<br\s*\/?>/i', "\n", $content);
-
- // Convert list items to dash prefix
- $content = preg_replace('/<li[^>]*>/i', '- ', $content);
- $content = str_replace('</li>', "\n", $content);
+ $content = $this->blocksToLines($content);
// Strip remaining HTML tags
$content = strip_tags($content);
@@ -153,6 +158,19 @@ class ContentSanitizer
return trim($content);
}
+ /**
+ * Block markup of older rich-editor posts as line breaks: a paragraph,
+ * heading, quote or line break ends a line and a list item starts with a dash.
+ */
+ private function blocksToLines(string $content): string
+ {
+ return (string) preg_replace(
+ ['~<p\b[^>]*>~i', '~<li\b[^>]*>~i', '~<br\s*/?>|</(?:p|li|div|h[1-6]|blockquote)>~i'],
+ ['', '- ', "\n"],
+ $content,
+ );
+ }
+
private function stripUnsafeHtml(string $content): string
{
// Mastodon accepts a subset of HTML: p, strong, em, a, br, span
diff --git a/app/Support/Mail/PostExcerpt.php b/app/Support/Mail/PostExcerpt.php
index f4564fa33..9c3e93593 100644
--- a/app/Support/Mail/PostExcerpt.php
+++ b/app/Support/Mail/PostExcerpt.php
@@ -4,22 +4,19 @@ declare(strict_types=1);
namespace App\Support\Mail;
+use App\Services\Social\ContentSanitizer;
use Illuminate\Support\Str;
/**
- * Plain-text excerpt of a post's editor HTML for emails: block tags and line
- * breaks become newlines, the rest of the markup is stripped and entities are
- * decoded, so the paragraphs of the post survive in a `pre-line` block.
+ * Plain-text excerpt of a post for emails, read like the networks read it
+ * (`ContentSanitizer::plainText()`): a typed `<` stays, the block tags of
+ * older rich-editor posts become newlines, so the paragraphs survive in a
+ * `pre-line` block.
*/
class PostExcerpt
{
public static function from(?string $html, int $limit): string
{
- $text = preg_replace('/<br\s*\/?>|<\/(p|div|li|h[1-6]|blockquote)>/i', "\n", (string) $html);
- $text = html_entity_decode(strip_tags((string) $text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
- $text = preg_replace("/[ \t]*\n[ \t]*/", "\n", $text);
- $text = preg_replace("/\n{3,}/", "\n\n", (string) $text);
-
- return Str::limit(trim((string) $text), $limit);
+ return Str::limit(app(ContentSanitizer::class)->plainText((string) $html), $limit);
}
}
diff --git a/app/Support/PostPlatformMetaRules.php b/app/Support/PostPlatformMetaRules.php
index fb91f3cc3..bc8cc60c7 100644
--- a/app/Support/PostPlatformMetaRules.php
+++ b/app/Support/PostPlatformMetaRules.php
@@ -66,6 +66,7 @@ class PostPlatformMetaRules
'platforms.*.meta.thread_replies.*.media.*' => ['array'],
'platforms.*.meta.thread_replies.*.media.*.id' => ['sometimes', 'nullable', 'string'],
'platforms.*.meta.thread_replies.*.media.*.upload_token' => ['sometimes', 'nullable', 'string'],
+ 'platforms.*.meta.thread_replies.*.media.*.url' => ['sometimes', 'nullable', 'string'],
'platforms.*.meta.document_title' => ['sometimes', 'nullable', 'string', 'max:300'],
@@ -234,20 +235,20 @@ class PostPlatformMetaRules
public static function documentation(): string
{
return implode(' ', [
- 'Per-platform metadata.',
+ 'Per-platform metadata. A thread on X, Bluesky or Mastodon is meta.thread_replies (see below).',
'TikTok: privacy_level PUBLIC_TO_EVERYONE|MUTUAL_FOLLOW_FRIENDS|FOLLOWER_OF_CREATOR|SELF_ONLY (required to publish; call get-tiktok-creator-info-tool first and pick one of its privacy_level_options, and keep allow_comments/allow_duet/allow_stitch false when it reports them disabled) + flags allow_comments, disclose (commercial content), brand_content_toggle (paid partnership), brand_organic_toggle (your own brand); on tiktok_video also allow_duet, allow_stitch and is_aigc (AI-generated content label), on tiktok_photo also auto_add_music. SELF_ONLY cannot be combined with brand_content_toggle.',
'Mastodon: spoiler_text (content warning, ≤500; counts toward the 500-character post limit).',
'Pinterest: board_id (required to publish — call list-pinterest-boards-tool first, or create-pinterest-board-tool), title (≤100), link (destination URL). Pin description comes from the post content; a video pin cover frame is the media item meta.cover_offset_ms.',
'Discord: channel_id (required to publish — call list-discord-channels-tool first), channel_name (the channel name shown in the app), mentions ([{token,label}], e.g. {token: "@everyone"} or {token: "<@&roleId>"}), embeds (up to 10 [{title ≤256, description ≤4096, url, image (URL), color (#RRGGBB)}]).',
'YouTube Shorts: title (≤100, no < or >; omitted, it is derived from the first non-empty line of the content with < and > removed, cut to 100 characters), description (plain text, at most 5000 bytes; omit or null to use the content), category_id (YouTube category id: '.collect(Category::cases())->map(fn (Category $category): string => "{$category->value}=".__($category->labelKey(), [], 'en'))->implode(', ').'; default '.Category::DEFAULT->value.'), privacy_status (public|unlisted|private, default public), license (youtube|creativeCommon), notify_subscribers (default true), embeddable (default true), made_for_kids (default false), is_ai_generated (discloses altered or synthetic content).',
- 'Instagram: is_ai_generated (feed, reels, stories, carousels), share_to_feed (reels, default true). People tags are the media item meta.user_tags and a video cover frame is meta.cover_offset_ms.',
+ 'Instagram: is_ai_generated (feed, reels, stories, carousels), share_to_feed (instagram_reel only, default true). An instagram_feed post with a single video publishes as a Reel. People tags are the media item meta.user_tags and a video cover frame is meta.cover_offset_ms.',
'X: is_ai_generated (sent as made_with_ai, discloses AI-generated media on the post).',
'Threads: topic_tag (1-50 characters after a leading # is dropped, no . or &). Use content_type threads_ghost_post for a text-only post archived after 24 hours (no media, no topic).',
'Facebook, Bluesky, LinkedIn: link_preview (default true; false publishes a text post with a link without its preview card).',
'LinkedIn (profile and page): document_title (≤300, the title shown on a PDF document post; defaults to the file name).',
'Google Business Profile: topic_type STANDARD (default)|EVENT|OFFER; call_to_action {action_type: '.implode('|', array_column(CtaAction::cases(), 'value')).', url} (not on OFFER; url required unless NONE or CALL); event {title ≤'.TopicType::TITLE_MAX_LENGTH.', start_date, end_date (YYYY-MM-DD), start_time, end_time (HH:MM)} (required on EVENT and OFFER, the title being the offer title); offer {coupon_code, redeem_online_url, terms_conditions ≤5000} (OFFER only).',
- 'Telegram, Facebook reels and stories, Instagram stories: no settings.',
- 'Threads of posts: thread_replies (list of up to '.ThreadReplies::MAX_REPLIES.' replies published under the post as a thread, each {text, media} where media is a list of up to 4 media items ({id} or {upload_token}, with optional meta.alt_text) for that reply alone; a plain string is a text-only reply) on Bluesky, Mastodon and X only; each reply needs text or media, its media follows the rules of a post on that network, and its text must fit the account limit (Bluesky 300, Mastodon 500 including the content warning, which every reply repeats, X 280 or 25000 for accounts with long posts).',
+ 'Telegram, Facebook reels and stories: no settings. Stories (Instagram and Facebook) publish no text.',
+ 'Threads of posts: thread_replies (list of up to '.ThreadReplies::MAX_REPLIES.' replies published under the post as a thread, each {text, media} where media is a list of up to 4 media items ({url}, {id} or {upload_token}, with optional meta.alt_text) for that reply alone; a plain string is a text-only reply) on Bluesky, Mastodon and X only; each reply needs text or media, its media follows the rules of a post on that network, and its text must fit the account limit (Bluesky 300, Mastodon 500 including the content warning, which every reply repeats, X 280 or 25000 for accounts with long posts).',
]);
}
@@ -419,6 +420,21 @@ class PostPlatformMetaRules
};
}
+ /**
+ * The meta keys a platform always needs before a post is scheduled or
+ * published, read from `requiredMetaViolation()` on empty meta. Meta that
+ * depends on other settings (a Google Business event) or that the text can
+ * stand in for (a YouTube title) is not listed.
+ *
+ * @return list<string>
+ */
+ public static function requiredMetaKeys(Platform $platform): array
+ {
+ $violation = self::requiredMetaViolation($platform, []);
+
+ return $violation === null ? [] : [$violation[0]];
+ }
+
/**
* Required meta that the post text can stand in for, so it is only missing
* once the text is known: a YouTube title falls back to the first line.
diff --git a/app/Support/Repurpose/DestinationMetaRules.php b/app/Support/Repurpose/DestinationMetaRules.php
index 8c2a41fc7..6a72e4d54 100644
--- a/app/Support/Repurpose/DestinationMetaRules.php
+++ b/app/Support/Repurpose/DestinationMetaRules.php
@@ -20,7 +20,10 @@ class DestinationMetaRules
*/
public static function rules(): array
{
- return self::reKey(PostPlatformMetaRules::rules());
+ return [
+ ...self::reKey(PostPlatformMetaRules::rules()),
+ 'destinations.*.meta.thread_replies.*.media.*.url' => ['prohibited'],
+ ];
}
/**
diff --git a/resources/js/components/analytics/workspace/AccountIdentity.vue b/resources/js/components/analytics/workspace/AccountIdentity.vue
index cf3fc6516..0c049c10e 100644
--- a/resources/js/components/analytics/workspace/AccountIdentity.vue
+++ b/resources/js/components/analytics/workspace/AccountIdentity.vue
@@ -11,6 +11,7 @@ import type { AccountIdentityData } from '@/types/analytics';
const props = defineProps<{
account: AccountIdentityData;
withAvatar?: boolean;
+ avatarSize?: 24 | 32;
color?: string;
}>();
const label = computed(() =>
@@ -37,6 +38,7 @@ const label = computed(() =>
:src="account.avatar_url"
:name="label"
ring="card"
+ :size="avatarSize ?? 32"
:status="account.status"
:account-id="account.social_account_key"
/>
diff --git a/resources/js/components/analytics/workspace/FollowersChart.vue b/resources/js/components/analytics/workspace/FollowersChart.vue
index 9aa95d688..af6810e5a 100644
--- a/resources/js/components/analytics/workspace/FollowersChart.vue
+++ b/resources/js/components/analytics/workspace/FollowersChart.vue
@@ -205,6 +205,8 @@ const rangeLabel = computed(
<AccountIdentity
:account="account"
:color="colors[account.social_account_key]"
+ with-avatar
+ :avatar-size="24"
/>
<span class="flex shrink-0 items-center gap-2">
<span class="text-sm font-semibold tabular-nums">
diff --git a/resources/js/components/analytics/workspace/PostsChart.vue b/resources/js/components/analytics/workspace/PostsChart.vue
index 1d74fbfd1..286f4ef3f 100644
--- a/resources/js/components/analytics/workspace/PostsChart.vue
+++ b/resources/js/components/analytics/workspace/PostsChart.vue
@@ -115,6 +115,8 @@ const rangeLabel = computed(
<AccountIdentity
:account="account"
:color="colors[account.social_account_key]"
+ with-avatar
+ :avatar-size="24"
/>
<span class="shrink-0 text-sm font-semibold tabular-nums">
{{ formatNumberCompact(account.count) }}
diff --git a/resources/js/components/analytics/workspace/charts/SocialAccountMetricBarChart.vue b/resources/js/components/analytics/workspace/charts/SocialAccountMetricBarChart.vue
index 72316abb5..047d14054 100644
--- a/resources/js/components/analytics/workspace/charts/SocialAccountMetricBarChart.vue
+++ b/resources/js/components/analytics/workspace/charts/SocialAccountMetricBarChart.vue
@@ -6,21 +6,18 @@ import {
VisStackedBarSelectors,
VisXYContainer,
} from '@unovis/vue';
-import { computed, getCurrentInstance } from 'vue';
+import { computed, getCurrentInstance, h, onBeforeUnmount, render } from 'vue';
+import ChannelAvatar from '@/components/ChannelAvatar.vue';
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
componentToString,
} from '@/components/ui/chart';
-import {
- getPlatformLabel,
- getPlatformLogo,
-} from '@/composables/usePlatformLogo';
+import { getPlatformLabel } from '@/composables/usePlatformLogo';
import { accountColor } from '@/lib/analyticsColors';
import type { AccountIdentityData } from '@/types/analytics';
-import { isConnectionLost } from '@/types/social-account';
import {
formatCountTick,
@@ -107,129 +104,57 @@ const tickAttributes = {
},
};
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
-const AVATAR_SIZE = 20;
-const BADGE_SIZE = 12;
-const AVATAR_GAP = 6;
-const chartUid = getCurrentInstance()?.uid ?? 0;
-
-const svgElement = (
- name: string,
- attributes: Record<string, string>,
-): SVGElement => {
- const element = document.createElementNS(SVG_NAMESPACE, name);
- Object.entries(attributes).forEach(([key, value]) =>
- element.setAttribute(key, value),
- );
-
- return element;
-};
+const AVATAR_SIZE = 24;
+const AVATAR_OVERHANG = 4;
+const AVATAR_GAP = 8;
+const appContext = getCurrentInstance()?.appContext ?? null;
+const avatarHosts: HTMLElement[] = [];
const accountLabel = (account: AccountIdentityData): string =>
account.username
? `@${account.username}`
: account.name || getPlatformLabel(account.platform);
-const buildAxisChannel = (
- account: AccountIdentityData,
- index: number,
-): SVGGElement => {
- const radius = AVATAR_SIZE / 2;
- const left = -AVATAR_SIZE - AVATAR_GAP;
- const centerX = left + radius;
- const clipId = `axis-avatar-clip-${chartUid}-${index}`;
- const group = svgElement('g', {
- 'data-account-logo': '',
- 'data-testid': 'analytics-axis-channel',
- }) as SVGGElement;
-
- const clip = svgElement('clipPath', { id: clipId });
- clip.appendChild(
- svgElement('circle', { cx: String(centerX), cy: '0', r: String(radius) }),
- );
- group.appendChild(clip);
-
- const fallback = svgElement('g', {
- 'data-testid': 'analytics-axis-avatar-fallback',
- });
- const fallbackCircle = svgElement('circle', {
- cx: String(centerX),
- cy: '0',
- r: String(radius),
- });
- fallbackCircle.style.fill = 'var(--secondary)';
- const initial = svgElement('text', {
- x: String(centerX),
- y: '0',
- 'text-anchor': 'middle',
- 'dominant-baseline': 'central',
- 'font-size': '9',
- 'font-weight': '700',
- });
- initial.style.fill = 'var(--foreground)';
- initial.textContent = (
- account.name ||
- account.username ||
- getPlatformLabel(account.platform)
- )
- .charAt(0)
- .toUpperCase();
- fallback.append(fallbackCircle, initial);
- group.appendChild(fallback);
-
- if (account.avatar_url) {
- const photo = svgElement('image', {
- href: account.avatar_url,
- x: String(left),
- y: String(-radius),
- width: String(AVATAR_SIZE),
- height: String(AVATAR_SIZE),
- 'clip-path': `url(#${clipId})`,
- preserveAspectRatio: 'xMidYMid slice',
- 'data-testid': 'analytics-axis-avatar',
- 'aria-label': accountLabel(account),
- });
- photo.addEventListener('error', () => photo.remove());
- group.appendChild(photo);
- }
+const unmountAvatars = (): void => {
+ avatarHosts.splice(0).forEach((host) => render(null, host));
+};
- const badgeCenterX = left + AVATAR_SIZE - BADGE_SIZE / 2 + 3;
- const badgeCenterY = radius - BADGE_SIZE / 2 + 2;
- const badgeRing = svgElement('circle', {
- cx: String(badgeCenterX),
- cy: String(badgeCenterY),
- r: String(BADGE_SIZE / 2 + 1),
+const buildAxisChannel = (account: AccountIdentityData): SVGElement => {
+ const box = AVATAR_SIZE + AVATAR_OVERHANG * 2;
+ const frame = document.createElementNS(SVG_NAMESPACE, 'foreignObject');
+ frame.setAttribute('x', String(-AVATAR_SIZE - AVATAR_GAP - AVATAR_OVERHANG));
+ frame.setAttribute('y', String(-AVATAR_SIZE / 2 - AVATAR_OVERHANG));
+ frame.setAttribute('width', String(box));
+ frame.setAttribute('height', String(box));
+ frame.setAttribute('data-account-logo', '');
+ frame.setAttribute('data-testid', 'analytics-axis-channel');
+ frame.setAttribute('data-platform', account.platform);
+ frame.style.overflow = 'visible';
+
+ const host = document.createElement('div');
+ host.style.padding = `${AVATAR_OVERHANG}px`;
+ host.style.lineHeight = '0';
+
+ const avatar = h(ChannelAvatar, {
+ platform: account.platform,
+ src: account.avatar_url,
+ name: accountLabel(account),
+ size: AVATAR_SIZE,
+ ring: 'card',
+ status: account.status ?? null,
+ accountId: account.social_account_key,
+ reserveSpace: false,
});
- badgeRing.style.fill = 'var(--card)';
- group.appendChild(badgeRing);
- group.appendChild(
- svgElement('image', {
- href: getPlatformLogo(account.platform),
- x: String(badgeCenterX - BADGE_SIZE / 2),
- y: String(badgeCenterY - BADGE_SIZE / 2),
- width: String(BADGE_SIZE),
- height: String(BADGE_SIZE),
- 'data-testid': 'analytics-axis-logo',
- 'aria-label': getPlatformLabel(account.platform),
- }),
- );
-
- if (isConnectionLost({ status: account.status ?? null })) {
- const dot = svgElement('circle', {
- cx: String(left + 2),
- cy: String(-radius + 2),
- r: '4',
- 'data-testid': 'analytics-axis-disconnected',
- });
- dot.style.fill = 'var(--destructive)';
- dot.style.stroke = 'var(--card)';
- dot.style.strokeWidth = '1.5';
- group.appendChild(dot);
- }
+ avatar.appContext = appContext;
+ render(avatar, host);
+ avatarHosts.push(host);
+ frame.appendChild(host);
- return group as SVGGElement;
+ return frame;
};
const decorateTicks = (svg: SVGSVGElement): void => {
+ unmountAvatars();
svg.querySelectorAll('[data-account-logo]').forEach((logo) =>
logo.remove(),
);
@@ -242,10 +167,12 @@ const decorateTicks = (svg: SVGSVGElement): void => {
return;
}
- tick.appendChild(buildAxisChannel(account, index));
+ tick.appendChild(buildAxisChannel(account));
},
);
};
+onBeforeUnmount(unmountAvatars);
+
const barAttributes = {
[VisStackedBarSelectors.bar]: { 'data-testid': 'analytics-account-bar' },
};
diff --git a/resources/js/components/analytics/workspace/charts/socialAccountChart.ts b/resources/js/components/analytics/workspace/charts/socialAccountChart.ts
index 10a234565..f77369ae0 100644
--- a/resources/js/components/analytics/workspace/charts/socialAccountChart.ts
+++ b/resources/js/components/analytics/workspace/charts/socialAccountChart.ts
@@ -1,8 +1,5 @@
import type { ChartConfig } from '@/components/ui/chart';
-import {
- getPlatformLabel,
- getPlatformLogo,
-} from '@/composables/usePlatformLogo';
+import { getPlatformLabel } from '@/composables/usePlatformLogo';
import { accountColor } from '@/lib/analyticsColors';
import { formatNumberCompact } from '@/lib/utils';
import type { AccountIdentityData } from '@/types/analytics';
@@ -12,17 +9,26 @@ export const socialAccountChartConfig = (
colors: Record<string, string>,
): ChartConfig =>
Object.fromEntries(
- accounts.map((account, index) => [
- `account_${index}`,
- {
- label: account.username
- ? `@${account.username}`
- : account.name || getPlatformLabel(account.platform),
- color:
- colors[account.social_account_key] ?? accountColor(index),
- icon: getPlatformLogo(account.platform),
- },
- ]),
+ accounts.map((account, index) => {
+ const label = account.username
+ ? `@${account.username}`
+ : account.name || getPlatformLabel(account.platform);
+
+ return [
+ `account_${index}`,
+ {
+ label,
+ color:
+ colors[account.social_account_key] ??
+ accountColor(index),
+ avatar: {
+ platform: account.platform,
+ name: label,
+ src: account.avatar_url,
+ },
+ },
+ ];
+ }),
);
export const formatCountTick = (tick: number | Date): string =>
diff --git a/resources/js/components/ui/chart/ChartTooltipContent.vue b/resources/js/components/ui/chart/ChartTooltipContent.vue
index 19a48d425..ab4164ec8 100644
--- a/resources/js/components/ui/chart/ChartTooltipContent.vue
+++ b/resources/js/components/ui/chart/ChartTooltipContent.vue
@@ -1,6 +1,8 @@
<script setup lang="ts">
import { computed } from 'vue';
+import ChannelAvatar from '@/components/ChannelAvatar.vue';
+
import { activeLocale } from '@/language';
import type { ChartConfig } from '.';
@@ -44,18 +46,20 @@ const entries = computed(() =>
<div class="grid gap-1">
<div v-for="entry in entries" :key="entry.key" class="grid gap-1">
<div class="flex items-center justify-between gap-4">
- <span class="inline-flex min-w-0 items-center gap-1.5">
+ <span class="inline-flex min-w-0 items-center gap-2">
<span
data-testid="analytics-tooltip-swatch"
class="size-2.5 shrink-0 rounded-[3px]"
:style="{ backgroundColor: entry.item.color }"
/>
- <img
- v-if="entry.item.icon"
- data-testid="analytics-tooltip-icon"
- :src="entry.item.icon"
- alt=""
- class="size-3 shrink-0 object-contain"
+ <ChannelAvatar
+ v-if="entry.item.avatar"
+ :platform="entry.item.avatar.platform"
+ :name="entry.item.avatar.name"
+ :src="entry.item.avatar.src"
+ :size="24"
+ ring="popover"
+ data-testid="analytics-tooltip-avatar"
/>
<span class="truncate">{{ entry.item.label }}</span>
</span>
diff --git a/resources/js/components/ui/chart/index.ts b/resources/js/components/ui/chart/index.ts
index 9ebcd13a3..b9a650b38 100644
--- a/resources/js/components/ui/chart/index.ts
+++ b/resources/js/components/ui/chart/index.ts
@@ -11,7 +11,11 @@ export { componentToString } from './utils';
export type ChartConfig = Record<
string,
- { label: string; color: string; icon?: string }
+ {
+ label: string;
+ color: string;
+ avatar?: { platform: string; name: string; src: string | null };
+ }
>;
interface ChartContext {
diff --git a/tests/Browser/ConnectConfirmationTest.php b/tests/Browser/ConnectConfirmationTest.php
index 1a24c60ae..b93448dd6 100644
--- a/tests/Browser/ConnectConfirmationTest.php
+++ b/tests/Browser/ConnectConfirmationTest.php
@@ -152,7 +152,6 @@ test('several pages: pick some, select all, and finish on the first connected ch
$page->click('@connect-finish');
- expect(connectConfirmPollFor($page, '/^\\/channels\\/[^\\/]+\\/publish$/.test(window.location.pathname)'))->toBeTrue();
waitForConnectConfirmTestId($page, 'goal-flow');
expect($user->currentWorkspace->socialAccounts()->pluck('platform_user_id')->sort()->values()->all())->toBe(['page-1', 'page-3']);
@@ -179,11 +178,12 @@ test('one identity is confirmed pre-checked and finishes on its channel page', f
$page->click('@connect-finish');
+ waitForConnectConfirmTestId($page, 'goal-flow');
+
$channel = $user->currentWorkspace->socialAccounts()->sole();
$channelPath = connectConfirmPath('app.channels.publish', $channel);
expect(connectConfirmPollFor($page, "window.location.pathname === '{$channelPath}'"))->toBeTrue();
- waitForConnectConfirmTestId($page, 'goal-flow');
expect($channel->platform)->toBe(Platform::X);
$page->assertVisible('@goal-flow')->assertNoJavaScriptErrors();
@@ -256,8 +256,9 @@ test('pages already connected stay in place, locked, uncounted and skipped by se
$page->click('@connect-finish');
- expect(connectConfirmPollFor($page, '/^\\/channels\\/[^\\/]+\\/publish$/.test(window.location.pathname)'))->toBeTrue()
- ->and($user->currentWorkspace->socialAccounts()->pluck('platform_user_id')->sort()->values()->all())->toBe(['page-1', 'page-2', 'page-3'])
+ waitForConnectConfirmTestId($page, 'goal-flow');
+
+ expect($user->currentWorkspace->socialAccounts()->pluck('platform_user_id')->sort()->values()->all())->toBe(['page-1', 'page-2', 'page-3'])
->and($connected->fresh()->access_token)->toBe('old-token');
$page->assertNoJavaScriptErrors();
@@ -574,6 +575,8 @@ test('a bluesky connection started without a return page finishes on its channel
$page->assertSee('Confirm Bluesky')->click('@connect-finish');
+ waitForConnectConfirmTestId($page, 'goal-flow');
+
$channel = $user->currentWorkspace->socialAccounts()->sole();
expect(connectConfirmPollFor($page, "window.location.pathname === '".connectConfirmPath('app.channels.publish', $channel)."'"))->toBeTrue()
diff --git a/tests/Browser/InsightsParityTest.php b/tests/Browser/InsightsParityTest.php
index 003d8333c..85d8673c9 100644
--- a/tests/Browser/InsightsParityTest.php
+++ b/tests/Browser/InsightsParityTest.php
@@ -228,19 +228,19 @@ test('followers and posts charts show network logos and say how many channels ar
$page = visit(route('app.insights'));
waitForInsightsParityTestId($page, 'accounts-unovis-bar-chart');
- waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-logo]").length >= 4');
+ waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-channel]").length >= 4');
- $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-logo]").length', 4)
+ $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel]").length', 4)
->assertScript('document.querySelector("[data-testid=analytics-followers-subtitle]")?.textContent.includes("Showing")', false);
$page->navigate(route('app.insights', ['channels' => [$instagram->id]]));
waitForInsightsParityTestId($page, 'analytics-followers-subtitle');
- waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-logo]").length >= 2');
+ waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-channel]").length >= 2');
$page->assertSeeIn('@analytics-followers-subtitle', 'Showing 1 of 2 channels. Filter by channel to see a different set.')
->assertSeeIn('@analytics-posts-subtitle', 'Showing 1 of 2 channels.')
- ->assertScript('document.querySelectorAll("[data-testid=analytics-axis-logo]").length', 2)
- ->assertScript('document.querySelector("[data-testid=analytics-axis-logo]").getAttribute("aria-label")', 'Instagram')
+ ->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel]").length', 2)
+ ->assertScript('document.querySelector("[data-testid=analytics-axis-channel]").getAttribute("data-platform")', 'instagram')
->assertNoJavaScriptErrors();
});
@@ -252,9 +252,9 @@ test('performance and follower charts show each channel as avatar plus network b
waitForInsightsParityTestId($page, 'accounts-unovis-bar-chart');
waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-channel]").length >= 4');
- $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-avatar]").length', 2)
- ->assertScript('document.querySelectorAll("[data-testid=analytics-axis-avatar-fallback]").length', 4)
- ->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel] [data-testid=analytics-axis-logo]").length', 4)
+ $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel] [data-slot=avatar] img").length', 2)
+ ->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel] [data-slot=avatar] > div").length', 2)
+ ->assertScript('[...document.querySelectorAll("[data-testid=analytics-axis-channel]")].every((channel) => channel.querySelectorAll("img").length >= 1)', true)
->assertScript('document.querySelectorAll("[data-testid=analytics-top-post-channel]").length >= 2', true)
->assertNoJavaScriptErrors();
});
@@ -266,9 +266,9 @@ test('a channel whose connection is lost shows the disconnected dot in the filte
$page = visit(route('app.insights'));
waitForInsightsParityTestId($page, 'analytics-channel-filter');
- waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-disconnected]").length >= 2');
+ waitForInsightsParityCondition($page, 'document.querySelectorAll("[data-testid=analytics-axis-channel] [data-testid^=channel-avatar-disconnected]").length >= 2');
- $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-disconnected]").length', 2)
+ $page->assertScript('document.querySelectorAll("[data-testid=analytics-axis-channel] [data-testid^=channel-avatar-disconnected]").length', 2)
->assertScript("document.querySelectorAll('[data-testid=\"channel-avatar-disconnected-{$facebook->id}\"]').length >= 1", true)
->click('@analytics-channel-filter');
waitForInsightsParityCondition($page, "document.querySelectorAll('[data-testid=\"channel-avatar-disconnected-{$facebook->id}\"]').length >= 2");
diff --git a/tests/Browser/WorkspaceInsightsTest.php b/tests/Browser/WorkspaceInsightsTest.php
index 9c17e36ef..43f1380c9 100644
--- a/tests/Browser/WorkspaceInsightsTest.php
+++ b/tests/Browser/WorkspaceInsightsTest.php
@@ -87,7 +87,7 @@ test('workspace dashboard separates accounts and switches follower and post char
->assertSee('Performance')
->assertPresent('@accounts-unovis-bar-chart')
->hover('[data-testid="analytics-account-bar"] >> nth=0')
- ->assertPresent('@analytics-tooltip-icon')
+ ->assertPresent('@analytics-tooltip-avatar')
->click('@followers-line')
->assertVisible('@followers-unovis-chart')
->click('@followers-growth')
@@ -98,7 +98,7 @@ test('workspace dashboard separates accounts and switches follower and post char
->click('@posts-stacked')
->assertVisible('@posts-unovis-chart')
->hover('[data-testid="analytics-post-bar"] >> nth=0')
- ->assertPresent('@analytics-tooltip-icon')
+ ->assertPresent('@analytics-tooltip-avatar')
->click('@top-comments')
->assertScript('(() => { const scroller = document.querySelector("[data-testid=app-layout-scroller]"); return ["auto", "scroll"].includes(getComputedStyle(scroller).overflowY) && scroller.scrollHeight > scroller.clientHeight; })()', true)
->assertScript('(() => { const scroller = document.querySelector("[data-testid=app-layout-scroller]"); const lastSection = Array.from(document.querySelectorAll("[data-testid=analytics-section]")).at(-1); return scroller.scrollHeight - (lastSection.getBoundingClientRect().bottom - scroller.getBoundingClientRect().top + scroller.scrollTop) >= 24; })()', true)
diff --git a/tests/Feature/Analytics/PublicationReconciliationTest.php b/tests/Feature/Analytics/PublicationReconciliationTest.php
index d22141f14..58c97326e 100644
--- a/tests/Feature/Analytics/PublicationReconciliationTest.php
+++ b/tests/Feature/Analytics/PublicationReconciliationTest.php
@@ -278,3 +278,10 @@ function discoveredPublication(
providerMetadata: ['source' => 'provider'],
);
}
+
+test('a less-than sign typed in a TryPost post stays in its analytics excerpt', function () {
+ [, $postPlatform] = publicationFixture('remote-lt');
+ $postPlatform->post->update(['content' => 'I <3 TryPost and price < 10']);
+
+ expect(app(SyncTryPostPublication::class)->handle($postPlatform->fresh())->excerpt)->toBe('I <3 TryPost and price < 10');
+});
diff --git a/tests/Feature/Analytics/WorkspaceAnalyticsReportTest.php b/tests/Feature/Analytics/WorkspaceAnalyticsReportTest.php
index 06552f3f1..521824d57 100644
--- a/tests/Feature/Analytics/WorkspaceAnalyticsReportTest.php
+++ b/tests/Feature/Analytics/WorkspaceAnalyticsReportTest.php
@@ -26,6 +26,7 @@ use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Queue;
+use Illuminate\Support\Facades\Storage;
beforeEach(function () {
Queue::fake([BootstrapAccountAnalytics::class, CollectAccountDailySnapshot::class]);
@@ -433,3 +434,53 @@ test('workspace report reuses date bounds already read by the controller', funct
expect($report['bounds'])->toBe($bounds);
});
+
+test('a live account shows its current avatar instead of the url frozen in the analytics rows', function () {
+ Storage::fake(null, ['url' => 'https://current-cdn.test']);
+ $workspace = Workspace::factory()->create();
+ $account = analyticsReportAccount($workspace, Platform::Instagram);
+ $account->forceFill(['avatar_url' => 'social-accounts/avatar.jpg'])->save();
+ analyticsReportFollower($account, '2026-09-05', 100);
+ $publication = analyticsReportPublication($account, '2026-09-05 10:00:00', 5, 1, 6, 100);
+ $publication->forceFill(['account_avatar_url' => 'https://old-cdn.test/social-accounts/avatar.jpg'])->save();
+ AnalyticsAccountDailySnapshot::query()->where('social_account_key', $account->id)->update(['account_avatar_url' => 'https://old-cdn.test/social-accounts/avatar.jpg']);
+
+ $report = app(BuildWorkspaceAnalyticsReport::class)->execute(
+ $workspace,
+ new DateRange(CarbonImmutable::parse('2026-09-01', 'UTC'), CarbonImmutable::parse('2026-09-10', 'UTC')),
+ );
+ $current = 'https://current-cdn.test/social-accounts/avatar.jpg';
+
+ expect($report['followers']['accounts'][0]['avatar_url'])->toBe($current)
+ ->and($report['posts']['accounts'][0]['avatar_url'])->toBe($current)
+ ->and($report['performance'][0]['avatar_url'])->toBe($current)
+ ->and($report['top_posts']['reactions'][0]['avatar_url'])->toBe($current);
+});
+
+test('a deleted account keeps the avatar stored in its analytics rows', function () {
+ $workspace = Workspace::factory()->create();
+ $account = analyticsReportAccount($workspace, Platform::Instagram);
+ $publication = analyticsReportPublication($account, '2026-09-05 10:00:00', 5, 1, 6, 100);
+ $publication->forceFill(['account_avatar_url' => 'https://old-cdn.test/avatar.jpg'])->save();
+ $account->delete();
+
+ $report = app(BuildWorkspaceAnalyticsReport::class)->execute(
+ $workspace,
+ new DateRange(CarbonImmutable::parse('2026-09-01', 'UTC'), CarbonImmutable::parse('2026-09-10', 'UTC')),
+ );
+
+ expect($report['performance'][0]['avatar_url'])->toBe('https://old-cdn.test/avatar.jpg');
+});
+
+test('publication detail shows the current avatar of a live account', function () {
+ Storage::fake(null, ['url' => 'https://current-cdn.test']);
+ $workspace = Workspace::factory()->create();
+ $account = analyticsReportAccount($workspace, Platform::Instagram);
+ $account->forceFill(['avatar_url' => 'social-accounts/avatar.jpg'])->save();
+ $publication = analyticsReportPublication($account, '2026-09-05 10:00:00', 5, 1, 6, 100);
+ $publication->forceFill(['account_avatar_url' => 'https://old-cdn.test/social-accounts/avatar.jpg'])->save();
+
+ $detail = app(ReadPublicationAnalytics::class)->latestForWorkspacePublication($workspace, $publication->id);
+
+ expect(data_get($detail, 'publication.account_avatar_url'))->toBe('https://current-cdn.test/social-accounts/avatar.jpg');
+});
diff --git a/tests/Feature/Api/PostMediaApiTest.php b/tests/Feature/Api/PostMediaApiTest.php
index cac42a619..a8147f96a 100644
--- a/tests/Feature/Api/PostMediaApiTest.php
+++ b/tests/Feature/Api/PostMediaApiTest.php
@@ -273,18 +273,18 @@ it('rejects upload of an unsupported mime type', function () {
});
it('rejects upload when the file type is not supported by enabled platforms', function () {
- $tiktokAccount = SocialAccount::factory()->tiktok()->create([
+ $youtubeAccount = SocialAccount::factory()->youtube()->create([
'workspace_id' => $this->workspace->id,
]);
- $tiktokOnlyPost = Post::factory()->create([
+ $youtubeOnlyPost = Post::factory()->create([
'workspace_id' => $this->workspace->id,
'user_id' => $this->user->id,
]);
- PostPlatform::factory()->tiktok()->create([
- 'post_id' => $tiktokOnlyPost->id,
- 'social_account_id' => $tiktokAccount->id,
+ PostPlatform::factory()->youtube()->create([
+ 'post_id' => $youtubeOnlyPost->id,
+ 'social_account_id' => $youtubeAccount->id,
'enabled' => true,
]);
@@ -294,7 +294,7 @@ it('rejects upload when the file type is not supported by enabled platforms', fu
);
$this->withHeaders(['Authorization' => 'Bearer '.$this->plainToken, 'Accept' => 'application/json'])
- ->post(route('api.posts.store-media', $tiktokOnlyPost), ['media' => $file])
+ ->post(route('api.posts.store-media', $youtubeOnlyPost), ['media' => $file])
->assertUnprocessable()
->assertJsonValidationErrors(['media']);
});
diff --git a/tests/Feature/Api/TikTokPhotoMediaTest.php b/tests/Feature/Api/TikTokPhotoMediaTest.php
new file mode 100644
index 000000000..0f5e1e717
--- /dev/null
+++ b/tests/Feature/Api/TikTokPhotoMediaTest.php
@@ -0,0 +1,84 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\PostPlatform\ContentType;
+use App\Enums\SocialAccount\Platform;
+use App\Jobs\Analytics\BootstrapAccountAnalytics;
+use App\Jobs\Analytics\CollectAccountDailySnapshot;
+use App\Models\Post;
+use App\Models\PostPlatform;
+use App\Models\SocialAccount;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Queue;
+use Illuminate\Support\Facades\Storage;
+
+beforeEach(function () {
+ Queue::fake([BootstrapAccountAnalytics::class, CollectAccountDailySnapshot::class]);
+ Storage::fake(null, ['url' => 'https://cdn.example.com']);
+
+ $result = createApiTestToken();
+ $this->user = $result['user'];
+ $this->workspace = $result['workspace'];
+ $this->headers = ['Authorization' => 'Bearer '.$result['plain_token']];
+ $this->tiktok = SocialAccount::factory()->tiktok()->create(['workspace_id' => $this->workspace->id]);
+
+ Http::fake([
+ 'example.com/*' => Http::response(
+ file_get_contents(base_path('tests/fixtures/1x1.png')),
+ 200,
+ ['Content-Type' => 'image/png'],
+ ),
+ ]);
+});
+
+test('an image url on a tiktok post is hosted and makes a tiktok photo', function () {
+ $response = $this->postJson(route('api.posts.store'), [
+ 'platforms' => [['social_account_id' => $this->tiktok->id]],
+ 'media' => [['url' => 'https://example.com/a.png']],
+ ], $this->headers);
+
+ $response->assertCreated();
+
+ $post = Post::query()->findOrFail($response->json('id'));
+
+ expect($post->media)->toHaveCount(1)
+ ->and($post->postPlatforms()->sole()->content_type)->toBe(ContentType::TikTokPhoto);
+});
+
+test('an image url attached to a tiktok post is added to the post', function () {
+ $post = Post::factory()->create(['workspace_id' => $this->workspace->id, 'user_id' => $this->user->id]);
+ PostPlatform::factory()->create([
+ 'post_id' => $post->id,
+ 'social_account_id' => $this->tiktok->id,
+ 'platform' => Platform::TikTok,
+ 'content_type' => ContentType::TikTokPhoto,
+ 'enabled' => true,
+ ]);
+
+ $this->postJson(route('api.posts.attach-media-from-url', $post), [
+ 'urls' => [['url' => 'https://example.com/b.png']],
+ ], $this->headers)->assertSuccessful();
+
+ expect($post->fresh()->media)->toHaveCount(1);
+});
+
+test('the content types listing says tiktok takes images and videos', function () {
+ $tiktok = collect($this->getJson(route('api.content-types'), $this->headers)->assertOk()->json('platforms'))
+ ->firstWhere('platform', Platform::TikTok->value);
+
+ expect($tiktok['allowed_media_types'])->toEqualCanonicalizing(['image', 'video']);
+});
+
+test('a tiktok video still refuses an image when it is scheduled', function () {
+ $this->postJson(route('api.posts.store'), [
+ 'status' => 'scheduled',
+ 'scheduled_at' => now()->addDay()->toIso8601String(),
+ 'platforms' => [[
+ 'social_account_id' => $this->tiktok->id,
+ 'content_type' => ContentType::TikTokVideo->value,
+ 'meta' => ['privacy_level' => 'SELF_ONLY'],
+ ]],
+ 'media' => [['url' => 'https://example.com/c.png']],
+ ], $this->headers)->assertUnprocessable();
+});
diff --git a/tests/Feature/Enums/SocialAccount/PlatformConnectableOptionsTest.php b/tests/Feature/Enums/SocialAccount/PlatformConnectableOptionsTest.php
index 6b944d7e3..68ec97710 100644
--- a/tests/Feature/Enums/SocialAccount/PlatformConnectableOptionsTest.php
+++ b/tests/Feature/Enums/SocialAccount/PlatformConnectableOptionsTest.php
@@ -76,6 +76,6 @@ test('connectable options expose each network capabilities for the details view'
->and(data_get($options, 'linkedin.analytics'))->toBeFalse()
->and(data_get($options, 'linkedin.media_types'))->toBe(['image', 'video', 'document'])
->and(data_get($options, 'tiktok.text_only'))->toBeFalse()
- ->and(data_get($options, 'tiktok.media_types'))->toBe(['video'])
+ ->and(data_get($options, 'tiktok.media_types'))->toBe(['image', 'video'])
->and(data_get($options, 'google_business.analytics'))->toBeFalse();
});
diff --git a/tests/Feature/Mcp/AttachMediaFromUrlToolTest.php b/tests/Feature/Mcp/AttachMediaFromUrlToolTest.php
index ac649cf61..340a0a7fc 100644
--- a/tests/Feature/Mcp/AttachMediaFromUrlToolTest.php
+++ b/tests/Feature/Mcp/AttachMediaFromUrlToolTest.php
@@ -246,3 +246,28 @@ test('requests the url uncompressed so a compressed bomb cannot expand on disk',
Http::assertSent(fn ($request) => $request->hasHeader('Accept-Encoding', 'identity'));
expect(Media::where('mediable_id', $this->workspace->id)->count())->toBe(0);
});
+
+test('attaches an image from url to a tiktok photo post', function () {
+ Http::fake([
+ 'example.com/photo.jpg' => Http::response(
+ file_get_contents(__DIR__.'/../../fixtures/1x1.png'),
+ 200,
+ ['Content-Type' => 'image/png'],
+ ),
+ ]);
+
+ $tiktok = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::TikTok]);
+ PostPlatform::factory()->create([
+ 'post_id' => $this->post->id, 'social_account_id' => $tiktok->id,
+ 'platform' => Platform::TikTok, 'content_type' => ContentType::TikTokPhoto, 'enabled' => true,
+ ]);
+
+ TryPostServer::actingAs($this->user)
+ ->tool(AttachMediaFromUrlTool::class, [
+ 'post_id' => $this->post->id,
+ 'urls' => [['url' => 'https://example.com/photo.jpg']],
+ ])
+ ->assertOk();
+
+ expect($this->post->fresh()->media)->toHaveCount(1);
+});
diff --git a/tests/Feature/Mcp/PlatformToolTest.php b/tests/Feature/Mcp/PlatformToolTest.php
index a3eb273bd..a3c9c11f8 100644
--- a/tests/Feature/Mcp/PlatformToolTest.php
+++ b/tests/Feature/Mcp/PlatformToolTest.php
@@ -27,6 +27,9 @@ test('list content types returns all platforms with constraints', function () {
'platform',
'label',
'max_content_length',
+ 'max_hashtags',
+ 'alt_text_max_length',
+ 'required_meta',
'recommended_content_length',
'allowed_media_types',
'default_content_type',
@@ -63,6 +66,10 @@ test('list content types returns all platforms with constraints', function () {
'supports_alt_text',
'supports_user_tags',
'supports_video_cover',
+ 'captionless',
+ 'document_must_be_alone',
+ 'supports_thread_replies',
+ 'max_thread_replies',
])
)
)
diff --git a/tests/Feature/Mcp/SocialAccountToolTest.php b/tests/Feature/Mcp/SocialAccountToolTest.php
index a4a13c5c1..cae6dc988 100644
--- a/tests/Feature/Mcp/SocialAccountToolTest.php
+++ b/tests/Feature/Mcp/SocialAccountToolTest.php
@@ -33,7 +33,7 @@ test('list returns wrapped social_accounts array with SocialAccountResource shap
$response->assertOk()
->assertStructuredContent(function (AssertableJson $json) {
$json->where('current_page', 1)->where('per_page', (int) config('app.pagination.default'))->etc()->has('social_accounts', 2, function (AssertableJson $account) {
- $account->hasAll(['id', 'platform', 'display_name', 'username', 'status', 'has_posting_schedule', 'timezone', 'posting_goal'])
+ $account->hasAll(['id', 'platform', 'display_name', 'username', 'status', 'has_posting_schedule', 'timezone', 'posting_goal', 'max_content_length', 'long_posts', 'verified_badge'])
->missing('is_active')
->missing('access_token')
->missing('refresh_token')
diff --git a/tests/Feature/Mcp/ToolDocumentationTest.php b/tests/Feature/Mcp/ToolDocumentationTest.php
new file mode 100644
index 000000000..5ecf60843
--- /dev/null
+++ b/tests/Feature/Mcp/ToolDocumentationTest.php
@@ -0,0 +1,182 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Mcp\Servers\TryPostServer;
+use App\Mcp\Tools\Idea\CreateIdeaTool;
+use App\Mcp\Tools\Label\CreateLabelTool;
+use App\Mcp\Tools\Label\UpdateLabelTool;
+use App\Mcp\Tools\Post\AttachMediaFromUploadTool;
+use App\Mcp\Tools\Post\AttachMediaFromUrlTool;
+use App\Mcp\Tools\Post\CreatePostsTool;
+use App\Mcp\Tools\Post\CreatePostTool;
+use App\Mcp\Tools\Post\DeletePostTool;
+use App\Mcp\Tools\Post\GetPostTool;
+use App\Mcp\Tools\Post\PreviewPostTool;
+use App\Mcp\Tools\Post\PublishPostTool;
+use App\Mcp\Tools\Post\SetPostRecurrenceTool;
+use App\Mcp\Tools\Post\UpdatePostTool;
+use App\Mcp\Tools\Repurpose\CreateRepurposeTool;
+use App\Mcp\Tools\Repurpose\UpdateRepurposeTool;
+use App\Mcp\Tools\Signature\CreateSignatureTool;
+use App\Mcp\Tools\Signature\ListSignaturesTool;
+use App\Mcp\Tools\SocialAccount\GeneratePostingScheduleTool;
+use App\Mcp\Tools\SocialAccount\GetTikTokCreatorInfoTool;
+use App\Mcp\Tools\SocialAccount\ListFreeSlotsTool;
+use App\Mcp\Tools\SocialAccount\ListSocialAccountsTool;
+use App\Mcp\Tools\SocialAccount\ReorderQueueTool;
+use App\Mcp\Tools\SocialAccount\UpdatePostingScheduleTool;
+use App\Mcp\Tools\Webhook\CreateWebhookTool;
+use App\Support\PostPlatformMetaRules;
+use Laravel\Mcp\Server\Attributes\Instructions;
+
+function mcpToolText(string $tool): string
+{
+ return json_encode(app($tool)->toArray(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
+}
+
+function mcpToolDescription(string $tool): string
+{
+ return app($tool)->toArray()['description'];
+}
+
+function mcpServerInstructions(): string
+{
+ return (new ReflectionClass(TryPostServer::class))->getAttributes(Instructions::class)[0]->newInstance()->value;
+}
+
+dataset('post writing tools', [
+ 'create-post' => [CreatePostTool::class],
+ 'create-posts' => [CreatePostsTool::class],
+ 'update-post' => [UpdatePostTool::class],
+]);
+
+test('post writing tools explain how to publish a thread', function (string $tool) {
+ expect(mcpToolDescription($tool))->toContain('thread_replies')->toContain('X, Bluesky or Mastodon');
+})->with('post writing tools');
+
+test('post writing tools say content is plain text', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('plain text')->not->toContain('<strong>')->not->toContain('or HTML');
+})->with('post writing tools');
+
+test('tools that schedule or publish list the required meta', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('privacy_level')->toContain('board_id')->toContain('channel_id')->toContain('required_meta');
+})->with([
+ 'create-post' => [CreatePostTool::class],
+ 'create-posts' => [CreatePostsTool::class],
+ 'update-post' => [UpdatePostTool::class],
+ 'publish-post' => [PublishPostTool::class],
+]);
+
+test('tools that change a post list the statuses that block it', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('partially_published')->toContain('failed');
+})->with([
+ 'update-post' => [UpdatePostTool::class],
+ 'delete-post' => [DeletePostTool::class],
+]);
+
+test('scheduled_at says it is utc and where the calendar ends', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('UTC')->toContain('2038-01-19');
+})->with([
+ 'create-post' => [CreatePostTool::class],
+ 'create-posts' => [CreatePostsTool::class],
+ 'update-post' => [UpdatePostTool::class],
+ 'publish-post' => [PublishPostTool::class],
+]);
+
+test('get-post says its times are utc', function () {
+ expect(mcpToolText(GetPostTool::class))->toContain('UTC');
+});
+
+test('delete-post says the post stays on the network', function () {
+ expect(mcpToolText(DeletePostTool::class))->toContain('never removed from the network');
+});
+
+test('the url attach tool lists the download limits', function () {
+ expect(mcpToolText(AttachMediaFromUrlTool::class))->toContain('20 seconds')->toContain('HEIC');
+});
+
+test('the upload attach tool names tools by their mcp name', function () {
+ expect(mcpToolText(AttachMediaFromUploadTool::class))->not->toContain('RequestMediaUploadTool')->toContain('request-media-upload-tool');
+});
+
+test('preview-post does not promise truncation', function () {
+ expect(mcpToolText(PreviewPostTool::class))->not->toContain('length truncation');
+});
+
+test('the meta documentation describes stories and single video feed posts', function () {
+ expect(PostPlatformMetaRules::documentation())
+ ->not->toContain('Instagram stories: no settings')
+ ->toContain('publishes as a Reel');
+});
+
+test('the server instructions mention threads, the queue and approvals', function () {
+ expect(mcpServerInstructions())->toContain('thread')->toContain('queue')->toContain('list-content-types-tool');
+});
+
+test('the posting schedule tools state their limits', function () {
+ expect(mcpToolText(UpdatePostingScheduleTool::class))->toContain('at most 4')->toContain('1 to 28')
+ ->and(mcpToolText(GeneratePostingScheduleTool::class))->toContain('1 to 28');
+});
+
+test('the queue tools state how many items they take', function () {
+ expect(mcpToolText(ListFreeSlotsTool::class))->toContain('30')
+ ->and(mcpToolText(ReorderQueueTool::class))->toContain('500');
+});
+
+test('the recurrence tool states its last possible occurrence', function () {
+ expect(mcpToolText(SetPostRecurrenceTool::class))->toContain('2037-12-31');
+});
+
+test('tiktok creator info says the video duration is not checked for the agent', function () {
+ expect(mcpToolText(GetTikTokCreatorInfoTool::class))->toContain('not checked');
+});
+
+test('signature tools say a signature is not added automatically', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('not added automatically');
+})->with([
+ 'create-signature' => [CreateSignatureTool::class],
+ 'list-signatures' => [ListSignaturesTool::class],
+]);
+
+test('label tools give the color format', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('#RRGGBB');
+})->with([
+ 'create-label' => [CreateLabelTool::class],
+ 'update-label' => [UpdateLabelTool::class],
+]);
+
+test('the idea tool states its limits', function () {
+ expect(mcpToolText(CreateIdeaTool::class))->toContain('10000');
+});
+
+test('the webhook tool explains the signature and the pause', function () {
+ expect(mcpToolText(CreateWebhookTool::class))->toContain('255')->toContain('X-Webhook-Signature')->toContain('5 failed');
+});
+
+test('repurpose tools give real schemas for formats, modes and destinations', function (string $tool) {
+ $properties = data_get(app($tool)->toArray(), 'inputSchema.properties');
+
+ expect(data_get($properties, 'source_format.enum'))->toBe(['reel', 'video', 'story'])
+ ->and(data_get($properties, 'publish_mode.enum'))->toBe(['publish', 'draft'])
+ ->and(array_keys(data_get($properties, 'destinations.items.properties')))->toBe(['social_account_id', 'content_type', 'meta']);
+})->with([
+ 'create-repurpose' => [CreateRepurposeTool::class],
+ 'update-repurpose' => [UpdateRepurposeTool::class],
+]);
+
+test('media url descriptions give the server limits, pixels included', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('megapixels')->not->toContain('workspace size limits')->not->toContain('workspace-wide');
+})->with([
+ 'attach-media-from-url' => [AttachMediaFromUrlTool::class],
+ 'create-post' => [CreatePostTool::class],
+]);
+
+test('the account listing and post text explain the x long post limit', function (string $tool) {
+ expect(mcpToolText($tool))->toContain('long_posts')->toContain('25000')->toContain('280');
+})->with([
+ 'list-social-accounts' => [ListSocialAccountsTool::class],
+ 'create-post' => [CreatePostTool::class],
+ 'create-posts' => [CreatePostsTool::class],
+ 'update-post' => [UpdatePostTool::class],
+]);
diff --git a/tests/Feature/Mcp/WorkspaceToolTest.php b/tests/Feature/Mcp/WorkspaceToolTest.php
index 90e43c67e..b584ad430 100644
--- a/tests/Feature/Mcp/WorkspaceToolTest.php
+++ b/tests/Feature/Mcp/WorkspaceToolTest.php
@@ -23,7 +23,7 @@ test('get workspace returns sanitized WorkspaceResource shape', function () {
->assertStructuredContent(function (AssertableJson $json) {
$json->where('id', $this->workspace->id)
->where('name', $this->workspace->name)
- ->hasAll(['created_at', 'updated_at'])
+ ->hasAll(['created_at', 'updated_at', 'me'])
->missing('account_id')
->missing('user_id')
->missing('brand_color')
diff --git a/tests/Feature/Parity/AccountLimitAndAccessParityTest.php b/tests/Feature/Parity/AccountLimitAndAccessParityTest.php
new file mode 100644
index 000000000..4148aeb79
--- /dev/null
+++ b/tests/Feature/Parity/AccountLimitAndAccessParityTest.php
@@ -0,0 +1,93 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\SocialAccount\Platform;
+use App\Mcp\Servers\TryPostServer;
+use App\Mcp\Tools\SocialAccount\ListSocialAccountsTool;
+use App\Mcp\Tools\Workspace\GetWorkspaceTool;
+use App\Models\SocialAccount;
+use App\Models\User;
+
+beforeEach(function () {
+ ['user' => $this->user, 'workspace' => $this->workspace, 'token' => $this->token] = parityContext();
+});
+
+function accountLimitMcpAccounts(User $user): array
+{
+ $accounts = null;
+
+ TryPostServer::actingAs($user)->tool(ListSocialAccountsTool::class, [])
+ ->assertOk()
+ ->assertStructuredContent(function ($json) use (&$accounts) {
+ $accounts = $json->toArray()['social_accounts'];
+ $json->etc();
+ });
+
+ return $accounts;
+}
+
+function accountLimitMcpWorkspace(User $user): array
+{
+ $workspace = null;
+
+ TryPostServer::actingAs($user)->tool(GetWorkspaceTool::class, [])
+ ->assertOk()
+ ->assertStructuredContent(function ($json) use (&$workspace) {
+ $workspace = $json->toArray();
+ $json->etc();
+ });
+
+ return $workspace;
+}
+
+test('each account lists its own text limit through api and mcp', function () {
+ $longX = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X, 'meta' => ['x_subscription_type' => 'Premium']]);
+ $plainX = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X, 'meta' => []]);
+ $linkedin = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::LinkedIn]);
+
+ $api = collect($this->withHeaders(parityApi($this->token))->getJson(route('api.social-accounts.index'))->assertOk()->json('data'))->keyBy('id');
+ $mcp = collect(accountLimitMcpAccounts($this->user))->keyBy('id');
+
+ foreach ([$api, $mcp] as $listing) {
+ expect($listing[$longX->id]['max_content_length'])->toBe(25000)
+ ->and($listing[$plainX->id]['max_content_length'])->toBe(280)
+ ->and($listing[$linkedin->id]['max_content_length'])->toBe(3000);
+ }
+});
+
+test('the workspace says what the caller may do through mcp', function (string $access, array $expected) {
+ $member = User::factory()->create(['account_id' => $this->workspace->account_id]);
+ $this->workspace->members()->attach($member->id, membershipPivot($access));
+ $member->update(['current_workspace_id' => $this->workspace->id]);
+
+ expect(accountLimitMcpWorkspace($member->fresh())['me'])->toBe($expected);
+})->with([
+ 'admin' => ['admin', ['is_admin' => true, 'requires_approval' => false, 'publishes_directly' => true]],
+ 'member' => ['member', ['is_admin' => false, 'requires_approval' => false, 'publishes_directly' => true]],
+ 'member who needs approval' => ['approval', ['is_admin' => false, 'requires_approval' => true, 'publishes_directly' => false]],
+]);
+
+test('the workspace owner is an admin who publishes directly through api and mcp', function () {
+ $expected = ['is_admin' => true, 'requires_approval' => false, 'publishes_directly' => true];
+
+ expect($this->withHeaders(parityApi($this->token))->getJson(route('api.workspace.show'))->assertOk()->json('me'))->toBe($expected)
+ ->and(accountLimitMcpWorkspace($this->user)['me'])->toBe($expected);
+});
+
+test('each x account says whether it has long posts and which badge it shows through api and mcp', function () {
+ $premium = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X, 'meta' => ['x_subscription_type' => 'Premium', 'x_verified_type' => 'blue']]);
+ $basic = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X, 'meta' => ['x_subscription_type' => 'Basic']]);
+ $government = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X, 'meta' => ['x_verified_type' => 'government']]);
+ $linkedin = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::LinkedIn]);
+
+ $api = collect($this->withHeaders(parityApi($this->token))->getJson(route('api.social-accounts.index'))->assertOk()->json('data'))->keyBy('id');
+ $mcp = collect(accountLimitMcpAccounts($this->user))->keyBy('id');
+
+ foreach ([$api, $mcp] as $listing) {
+ expect($listing[$premium->id])->toMatchArray(['long_posts' => true, 'verified_badge' => 'blue', 'max_content_length' => 25000])
+ ->and($listing[$basic->id])->toMatchArray(['long_posts' => true, 'verified_badge' => null, 'max_content_length' => 25000])
+ ->and($listing[$government->id])->toMatchArray(['long_posts' => false, 'verified_badge' => 'government', 'max_content_length' => 280])
+ ->and($listing[$linkedin->id])->toMatchArray(['long_posts' => false, 'verified_badge' => null]);
+ }
+});
diff --git a/tests/Feature/Parity/ChannelsParityTest.php b/tests/Feature/Parity/ChannelsParityTest.php
index c00c7d08b..e4dde972a 100644
--- a/tests/Feature/Parity/ChannelsParityTest.php
+++ b/tests/Feature/Parity/ChannelsParityTest.php
@@ -36,7 +36,7 @@ test('listing channels returns the same accounts on the api and mcp, including t
TryPostServer::actingAs($this->user)->tool(ListSocialAccountsTool::class)->assertOk()->assertStructuredContent(parityMcpPage('social_accounts', $apiResponse));
expect(collect($api)->pluck('id')->sort()->values()->all())->toBe(collect([$first->id, $second->id])->sort()->values()->all())
- ->and(array_keys($api[0]))->toEqual(['id', 'platform', 'display_name', 'username', 'status', 'has_posting_schedule', 'timezone', 'posting_goal'])
+ ->and(array_keys($api[0]))->toEqual(['id', 'platform', 'display_name', 'username', 'status', 'has_posting_schedule', 'timezone', 'posting_goal', 'max_content_length', 'long_posts', 'verified_badge'])
->and(collect($api)->firstWhere('id', $first->id)['timezone'])->toBe('America/Sao_Paulo');
});
diff --git a/tests/Feature/Parity/ContentTypesListingParityTest.php b/tests/Feature/Parity/ContentTypesListingParityTest.php
new file mode 100644
index 000000000..acdb532b2
--- /dev/null
+++ b/tests/Feature/Parity/ContentTypesListingParityTest.php
@@ -0,0 +1,82 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Mcp\Servers\TryPostServer;
+use App\Mcp\Tools\Platform\ListContentTypesTool;
+
+beforeEach(function () {
+ ['user' => $this->user, 'workspace' => $this->workspace, 'token' => $this->token] = parityContext();
+});
+
+function contentTypesListingApi(object $test): array
+{
+ return $test->withHeaders(parityApi($test->token))->getJson(route('api.content-types'))->assertOk()->json('platforms');
+}
+
+function contentTypesListingPlatform(array $platforms, string $platform): array
+{
+ return collect($platforms)->firstWhere('platform', $platform);
+}
+
+function contentTypesListingType(array $platforms, string $platform, string $type): array
+{
+ return collect(contentTypesListingPlatform($platforms, $platform)['content_types'])->firstWhere('value', $type);
+}
+
+test('api and mcp list exactly the same platforms payload', function () {
+ $mcp = null;
+
+ TryPostServer::actingAs($this->user)->tool(ListContentTypesTool::class, [])
+ ->assertOk()
+ ->assertStructuredContent(function ($json) use (&$mcp) {
+ $mcp = $json->toArray()['platforms'];
+ $json->etc();
+ });
+
+ expect($mcp)->toEqual(contentTypesListingApi($this));
+});
+
+test('content types say which ones publish no text', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingType($platforms, 'instagram', 'instagram_story')['captionless'])->toBeTrue()
+ ->and(contentTypesListingType($platforms, 'instagram', 'instagram_feed')['captionless'])->toBeFalse();
+});
+
+test('content types say a document must be the only attachment', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingType($platforms, 'linkedin', 'linkedin_post')['document_must_be_alone'])->toBeTrue()
+ ->and(contentTypesListingType($platforms, 'x', 'x_post')['document_must_be_alone'])->toBeFalse();
+});
+
+test('content types say where thread replies are supported and how many', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingType($platforms, 'x', 'x_post'))
+ ->toMatchArray(['supports_thread_replies' => true, 'max_thread_replies' => 24])
+ ->and(contentTypesListingType($platforms, 'bluesky', 'bluesky_post')['supports_thread_replies'])->toBeTrue()
+ ->and(contentTypesListingType($platforms, 'instagram', 'instagram_feed'))
+ ->toMatchArray(['supports_thread_replies' => false, 'max_thread_replies' => null]);
+});
+
+test('platforms list the meta required to schedule or publish', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingPlatform($platforms, 'tiktok')['required_meta'])->toBe(['privacy_level'])
+ ->and(contentTypesListingPlatform($platforms, 'pinterest')['required_meta'])->toBe(['board_id'])
+ ->and(contentTypesListingPlatform($platforms, 'discord')['required_meta'])->toBe(['channel_id'])
+ ->and(contentTypesListingPlatform($platforms, 'linkedin')['required_meta'])->toBe([]);
+});
+
+test('platforms list hashtag, alt text and long post limits', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingPlatform($platforms, 'instagram'))
+ ->toMatchArray(['max_hashtags' => 5])
+ ->and(contentTypesListingPlatform($platforms, 'linkedin')['max_hashtags'])->toBeNull()
+ ->and(contentTypesListingPlatform($platforms, 'x'))
+ ->toMatchArray(['max_content_length' => 280, 'alt_text_max_length' => 1000])
+ ->not->toHaveKey('long_post_content_length');
+});
diff --git a/tests/Feature/Parity/MediaParityTest.php b/tests/Feature/Parity/MediaParityTest.php
index ff58e31ce..f3dd04428 100644
--- a/tests/Feature/Parity/MediaParityTest.php
+++ b/tests/Feature/Parity/MediaParityTest.php
@@ -32,7 +32,11 @@ function mediaParityPost(object $test, string $platform = 'linkedin'): Post
$post = Post::factory()->create(['workspace_id' => $test->workspace->id, 'user_id' => $test->user->id]);
$account = SocialAccount::factory()->create([
'workspace_id' => $test->workspace->id,
- 'platform' => $platform === 'tiktok' ? Platform::TikTok : Platform::LinkedIn,
+ 'platform' => match ($platform) {
+ 'tiktok' => Platform::TikTok,
+ 'youtube' => Platform::YouTube,
+ default => Platform::LinkedIn,
+ },
]);
PostPlatform::factory()->{$platform}()->create(['post_id' => $post->id, 'social_account_id' => $account->id, 'enabled' => true]);
@@ -122,8 +126,8 @@ test('an expired or unknown upload token is refused by both surfaces', function
});
test('a media type the enabled network does not accept is refused by both surfaces', function () {
- $apiPost = mediaParityPost($this, 'tiktok');
- $mcpPost = mediaParityPost($this, 'tiktok');
+ $apiPost = mediaParityPost($this, 'youtube');
+ $mcpPost = mediaParityPost($this, 'youtube');
$apiUpload = mediaParityUpload($this);
$mcpUpload = mediaParityUpload($this);
@@ -266,8 +270,8 @@ test('user tags and a video cover frame set through the api update and the mcp u
});
test('a media type the network does not accept gets the same translated message on both surfaces', function () {
- $apiPost = mediaParityPost($this, 'tiktok');
- $mcpPost = mediaParityPost($this, 'tiktok');
+ $apiPost = mediaParityPost($this, 'youtube');
+ $mcpPost = mediaParityPost($this, 'youtube');
$message = __('posts.errors.media_type_unsupported');
$this->withHeaders(parityApi($this->token))
diff --git a/tests/Feature/Parity/RepurposeParityTest.php b/tests/Feature/Parity/RepurposeParityTest.php
index a5429079d..4af8894cc 100644
--- a/tests/Feature/Parity/RepurposeParityTest.php
+++ b/tests/Feature/Parity/RepurposeParityTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
use App\Enums\PostPlatform\ContentType;
use App\Enums\Repurpose\SourceFormat;
use App\Enums\Repurpose\Status;
+use App\Enums\SocialAccount\Platform;
use App\Mcp\Servers\TryPostServer;
use App\Mcp\Tools\Repurpose\ActivateRepurposeTool;
use App\Mcp\Tools\Repurpose\CreateRepurposeTool;
@@ -347,3 +348,33 @@ test('the shared repurpose rules validate from an explicit workspace without a r
expect(fn () => RepurposeRequestRules::validate(['source_format' => 'reel'], $this->workspace->id))
->toThrow(ValidationException::class);
});
+
+test('a reply media url in a repurpose destination is refused by the web update, the api and mcp', function () {
+ $x = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::X]);
+ $repurpose = Repurpose::factory()->create([
+ 'workspace_id' => $this->workspace->id,
+ 'user_id' => $this->user->id,
+ 'source_social_account_id' => $this->instagram->id,
+ ]);
+ $destinations = [[
+ 'social_account_id' => $x->id,
+ 'content_type' => ContentType::XPost->value,
+ 'meta' => ['thread_replies' => [['text' => 'Two', 'media' => [['url' => 'https://example.com/reply.png']]]]],
+ ]];
+ $field = 'destinations.0.meta.thread_replies.0.media.0.url';
+
+ $this->actingAs($this->user)
+ ->putJson(route('app.repurposes.update', $repurpose), ['destinations' => $destinations])
+ ->assertJsonValidationErrors([$field]);
+
+ auth()->forgetGuards();
+ $this->withHeaders(parityApi($this->token))
+ ->putJson(route('api.repurposes.update', $repurpose), ['destinations' => $destinations])
+ ->assertJsonValidationErrors([$field]);
+
+ TryPostServer::actingAs($this->user)
+ ->tool(UpdateRepurposeTool::class, ['repurpose_id' => $repurpose->id, 'destinations' => $destinations])
+ ->assertHasErrors();
+
+ expect($repurpose->fresh()->destinations)->toBe([]);
+});
diff --git a/tests/Feature/Parity/ThreadReplyMediaUrlParityTest.php b/tests/Feature/Parity/ThreadReplyMediaUrlParityTest.php
new file mode 100644
index 000000000..b95374053
--- /dev/null
+++ b/tests/Feature/Parity/ThreadReplyMediaUrlParityTest.php
@@ -0,0 +1,110 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\PostPlatform\ContentType;
+use App\Enums\SocialAccount\Platform;
+use App\Mcp\Servers\TryPostServer;
+use App\Mcp\Tools\Post\CreatePostsTool;
+use App\Mcp\Tools\Post\CreatePostTool;
+use App\Mcp\Tools\Post\UpdatePostTool;
+use App\Models\Post;
+use App\Models\PostPlatform;
+use App\Models\SocialAccount;
+use Illuminate\Support\Facades\Http;
+use Illuminate\Support\Facades\Storage;
+
+beforeEach(function () {
+ Storage::fake();
+ ['user' => $this->user, 'workspace' => $this->workspace, 'token' => $this->token] = parityContext();
+ $this->account = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Bluesky]);
+
+ Http::fake([
+ 'example.com/missing.png' => fn () => Http::response('', 404),
+ 'example.com/*' => fn () => Http::response(file_get_contents(base_path('tests/fixtures/1x1.png')), 200, ['Content-Type' => 'image/png']),
+ ]);
+});
+
+function threadReplyUrlMeta(string $url = 'https://example.com/reply.png'): array
+{
+ return ['thread_replies' => [['text' => 'Second', 'media' => [['url' => $url]]]]];
+}
+
+function threadReplyStoredMedia(PostPlatform $target): array
+{
+ return data_get($target->fresh()->meta, 'thread_replies.0.media', []);
+}
+
+test('a reply media url is hosted on create through api and mcp', function () {
+ $payload = [
+ 'content' => 'First',
+ 'platforms' => [['social_account_id' => $this->account->id, 'content_type' => ContentType::BlueskyPost->value, 'meta' => threadReplyUrlMeta()]],
+ ];
+
+ $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.store'), $payload)->assertCreated();
+ TryPostServer::actingAs($this->user)->tool(CreatePostTool::class, $payload)->assertOk();
+
+ $targets = PostPlatform::query()->with('post')->where('social_account_id', $this->account->id)->get();
+
+ expect($targets)->toHaveCount(2);
+
+ foreach ($targets as $target) {
+ $media = threadReplyStoredMedia($target);
+
+ expect($media)->toHaveCount(1)
+ ->and(data_get($media, '0.type'))->toBe('image')
+ ->and($target->post->ownedMedia()->count())->toBe(1);
+ }
+});
+
+test('a reply media url is hosted in a batch through api and mcp', function () {
+ $payload = [
+ 'status' => 'draft',
+ 'content' => 'First',
+ 'destinations' => [['social_account_id' => $this->account->id, 'content_type' => ContentType::BlueskyPost->value, 'meta' => threadReplyUrlMeta()]],
+ ];
+
+ $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.batch.store'), $payload)->assertCreated();
+ TryPostServer::actingAs($this->user)->tool(CreatePostsTool::class, $payload)->assertOk();
+
+ $targets = PostPlatform::query()->where('social_account_id', $this->account->id)->get();
+
+ expect($targets)->toHaveCount(2)
+ ->and(threadReplyStoredMedia($targets[0]))->toHaveCount(1)
+ ->and(threadReplyStoredMedia($targets[1]))->toHaveCount(1);
+});
+
+test('a reply media url is hosted on update through api and mcp', function () {
+ $posts = collect([0, 1])->map(function (): Post {
+ $post = Post::factory()->create(['workspace_id' => $this->workspace->id, 'user_id' => $this->user->id]);
+ PostPlatform::factory()->create([
+ 'post_id' => $post->id,
+ 'social_account_id' => $this->account->id,
+ 'platform' => Platform::Bluesky,
+ 'content_type' => ContentType::BlueskyPost,
+ 'enabled' => true,
+ ]);
+
+ return $post;
+ });
+
+ $this->withHeaders(parityApi($this->token))->putJson(route('api.posts.update', $posts[0]), ['meta' => threadReplyUrlMeta()])->assertOk();
+ TryPostServer::actingAs($this->user)->tool(UpdatePostTool::class, ['post_id' => $posts[1]->id, 'meta' => threadReplyUrlMeta()])->assertOk();
+
+ foreach ($posts as $post) {
+ expect(threadReplyStoredMedia($post->postPlatforms()->sole()))->toHaveCount(1);
+ }
+});
+
+test('an unreachable reply media url is refused instead of dropped through api and mcp', function () {
+ $payload = [
+ 'content' => 'First',
+ 'platforms' => [['social_account_id' => $this->account->id, 'content_type' => ContentType::BlueskyPost->value, 'meta' => threadReplyUrlMeta('https://example.com/missing.png')]],
+ ];
+
+ $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.store'), $payload)
+ ->assertJsonValidationErrors(['platforms.0.meta.thread_replies.0.media.0.url']);
+ TryPostServer::actingAs($this->user)->tool(CreatePostTool::class, $payload)->assertHasErrors();
+
+ expect(Post::query()->where('workspace_id', $this->workspace->id)->count())->toBe(0);
+});
diff --git a/tests/Feature/Parity/WorkspaceParityTest.php b/tests/Feature/Parity/WorkspaceParityTest.php
index ce85054b0..9e6a88a1b 100644
--- a/tests/Feature/Parity/WorkspaceParityTest.php
+++ b/tests/Feature/Parity/WorkspaceParityTest.php
@@ -17,7 +17,7 @@ test('showing the workspace returns the same fields on the api and mcp, without
TryPostServer::actingAs($this->user)->tool(GetWorkspaceTool::class)->assertOk()->assertStructuredContent($api);
- expect(array_keys($api))->toBe(['id', 'name', 'created_at', 'updated_at'])
+ expect(array_keys($api))->toBe(['id', 'name', 'created_at', 'updated_at', 'me'])
->and($api['id'])->toBe($this->workspace->id)
->and($api['name'])->toBe($this->workspace->name);
});
diff --git a/tests/Feature/Posts/ImportExternalPostsTest.php b/tests/Feature/Posts/ImportExternalPostsTest.php
index 926757be2..bac9d2de8 100644
--- a/tests/Feature/Posts/ImportExternalPostsTest.php
+++ b/tests/Feature/Posts/ImportExternalPostsTest.php
@@ -577,3 +577,25 @@ test('the live part of a thread that failed midway is never imported as external
->and(PostPlatform::where('platform_post_id', 'other-1')->exists())->toBeTrue()
->and(AnalyticsPublication::whereIn('remote_id', ['root-1', 'reply-1'])->whereNotNull('post_platform_id')->exists())->toBeFalse();
});
+
+test('captions that differ only after a less-than sign are not linked', function () {
+ $account = SocialAccount::factory()->instagram()->create();
+ $tryPost = sentByTryPost($account, 'container-1', 'We <3 apples and pears', now()->subHour()->toImmutable());
+ externalPublication($account, ['remote_id' => 'media-1', 'excerpt' => 'We <3 bananas', 'provider_published_at' => now()->subHour()]);
+
+ ImportExternalPosts::execute($account);
+
+ expect(Post::query()->imported()->count())->toBe(1)
+ ->and($tryPost->fresh()->platform_post_id)->toBe('container-1');
+});
+
+test('a caption with a less-than sign links to its own publication', function () {
+ $account = SocialAccount::factory()->instagram()->create();
+ $tryPost = sentByTryPost($account, 'container-1', 'We <3 apples and pears', now()->subHour()->toImmutable());
+ externalPublication($account, ['remote_id' => 'media-1', 'excerpt' => 'We <3 apples and pears', 'provider_published_at' => now()->subHour()]);
+
+ ImportExternalPosts::execute($account);
+
+ expect(Post::query()->imported()->count())->toBe(0)
+ ->and($tryPost->fresh()->platform_post_id)->toBe('media-1');
+});
diff --git a/tests/Feature/Services/Social/ContentSanitizerTest.php b/tests/Feature/Services/Social/ContentSanitizerTest.php
index 91e7c0d9b..3a9787415 100644
--- a/tests/Feature/Services/Social/ContentSanitizerTest.php
+++ b/tests/Feature/Services/Social/ContentSanitizerTest.php
@@ -105,7 +105,7 @@ test('it keeps telegram-allowed html and converts strong/em', function () {
test('it strips disallowed tags but keeps links for telegram', function () {
$sanitizer = new ContentSanitizer;
$result = $sanitizer->sanitize('<div>see <a href="https://example.com">link</a></div><script>x</script>', Platform::Telegram);
- expect($result)->toBe('see <a href="https://example.com">link</a>x');
+ expect($result)->toBe("see <a href=\"https://example.com\">link</a>\nx");
});
test('it escapes bare ampersands for telegram', function () {
@@ -412,3 +412,16 @@ test('it strips mastodon markup for length without decoding its entities twice',
expect($sanitizer->displayText($content, Platform::Mastodon))->toBe('Tom &amp; Jerry');
});
+
+test('a less-than sign typed as text is published, not read as a tag', function (Platform $platform) {
+ expect(app(ContentSanitizer::class)->displayText("I <3 TryPost\nprice < 10 and > 5", $platform))
+ ->toBe("I <3 TryPost\nprice < 10 and > 5");
+})->with([Platform::X, Platform::LinkedIn, Platform::Instagram, Platform::Mastodon, Platform::Telegram]);
+
+test('telegram receives a typed less-than sign escaped for its html parser', function () {
+ expect(app(ContentSanitizer::class)->sanitize('I <3 TryPost & co', Platform::Telegram))->toBe('I &lt;3 TryPost &amp; co');
+});
+
+test('content written by the former rich editor still loses its tags', function () {
+ expect(app(ContentSanitizer::class)->sanitize('<p>Hello <strong>world</strong> &lt;3</p><p>Bye</p>', Platform::X))->toBe("Hello world <3\nBye");
+});
diff --git a/tests/Unit/Enums/PlatformMediaTypesTest.php b/tests/Unit/Enums/PlatformMediaTypesTest.php
new file mode 100644
index 000000000..282593701
--- /dev/null
+++ b/tests/Unit/Enums/PlatformMediaTypesTest.php
@@ -0,0 +1,23 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\PostPlatform\ContentType;
+use App\Enums\SocialAccount\Platform;
+
+test('a platform allows exactly the media kinds its content types accept', function (Platform $platform) {
+ $accepted = collect(ContentType::forPlatform($platform))
+ ->flatMap(fn (ContentType $type): array => array_keys(array_filter([
+ 'image' => $type->supportsImage(),
+ 'video' => $type->supportsVideo(),
+ 'document' => $type->supportsDocument(),
+ ])))
+ ->unique()
+ ->sort()
+ ->values()
+ ->all();
+
+ $allowed = collect($platform->allowedMediaTypes())->map->value->sort()->values()->all();
+
+ expect($allowed)->toBe($accepted);
+})->with(Platform::cases());
diff --git a/tests/Unit/Enums/PlatformTest.php b/tests/Unit/Enums/PlatformTest.php
index 9a24feb9f..6f89da0fc 100644
--- a/tests/Unit/Enums/PlatformTest.php
+++ b/tests/Unit/Enums/PlatformTest.php
@@ -40,7 +40,7 @@ test('platform has correct allowed media types', function () {
expect(Platform::LinkedInPage->allowedMediaTypes())->toContain(MediaType::Image, MediaType::Video, MediaType::Document);
expect(Platform::X->allowedMediaTypes())->toContain(MediaType::Image, MediaType::Video);
expect(Platform::X->allowedMediaTypes())->not->toContain(MediaType::Document);
- expect(Platform::TikTok->allowedMediaTypes())->toBe([MediaType::Video]);
+ expect(Platform::TikTok->allowedMediaTypes())->toBe([MediaType::Image, MediaType::Video]);
expect(Platform::YouTube->allowedMediaTypes())->toBe([MediaType::Video]);
expect(Platform::Instagram->allowedMediaTypes())->toContain(MediaType::Image, MediaType::Video);
});
diff --git a/tests/Unit/Support/Mail/PostExcerptTest.php b/tests/Unit/Support/Mail/PostExcerptTest.php
new file mode 100644
index 000000000..f1d35c1ea
--- /dev/null
+++ b/tests/Unit/Support/Mail/PostExcerptTest.php
@@ -0,0 +1,13 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Support\Mail\PostExcerpt;
+
+test('a less-than sign typed in the post stays in the email excerpt', function () {
+ expect(PostExcerpt::from("I <3 TryPost\nprice < 10", 200))->toBe("I <3 TryPost\nprice < 10");
+});
+
+test('an excerpt of a post from the former rich editor keeps its paragraphs', function () {
+ expect(PostExcerpt::from('<p>Hello <strong>world</strong></p><p>Bye</p>', 200))->toBe("Hello world\nBye");
+});
diff --git a/tests/fixtures/display-length-corpus.json b/tests/fixtures/display-length-corpus.json
index 1b2bc1123..cb0ec66a8 100644
--- a/tests/fixtures/display-length-corpus.json
+++ b/tests/fixtures/display-length-corpus.json
@@ -16,5 +16,9 @@
"#hashtag @mention https://example.com/path?x=1",
"",
" ",
- "\n\n\n"
+ "\n\n\n",
+ "I <3 TryPost and everything after it",
+ "price < 10 and > 5",
+ "a<b c<d",
+ "<3 at the start"
]