trypost/app/Http/Controllers/App
Paulo Castellano 6496588bbc
Defuse links in X posts to avoid the link-post fee (#308)
X bills a post containing a URL at a much higher rate than a plain post, and
its algorithm demotes link posts. The X version of a post now rewrites every
URL non-clickable (https://example.com/post becomes example(.)com/post):
scheme and www. dropped, every dot of the host replaced with (.).

Leaving a single dot intact would still leave a resolvable domain for X to
detect, so all of them are broken. A scheme or www. proves a token is a URL on
its own; a bare host only counts when its last label is a delegated TLD, which
is the one thing telling acme.com apart from Node.js. That check runs against
App\Support\LinkTlds, generated from the whole IANA root zone in every form a
TLD can appear in a post -- ASCII, punycode and the Unicode it decodes to --
because whatever X links is what X bills, so a hand-picked subset would leave
us paying for its gaps. If the regex engine bails out on pathological input the
original content is returned instead of crashing the publisher.

The transform lives in the Platform::X arm of ContentSanitizer, so it reaches
publishing and the app/API/MCP previews from one place and cannot touch any
other network. Off by default; opt in with X_DEFUSE_LINKS.

The editor counts characters and renders its preview client-side and cannot ask
the server on every keystroke, so the rewrite is mirrored in TypeScript. PHP
stays the source of truth: a parity test fails if the two TLD sets drift, and a
browser test drives the real editor so the mirror is covered rather than
assumed. Without it the composer promised text the network never receives.

Character limits now measure the text a reader will see: sanitized, then with
markup resolved away. Measuring the raw draft blocked saving posts that publish
fine and let through posts the network rejects, and counted the editor's HTML
toward the limit. Measuring the sanitized form alone would have counted
Telegram's escaped entities, rejecting messages Telegram accepts.

Empty content is handled once inside the sanitizer instead of by a guard
repeated at every call site.
2026-08-29 15:31:05 -03:00
..
Settings feat: fire signup/checkout PostHog events from the backend (#277) 2026-08-12 11:47:47 -03:00
AnalyticsController.php Remove the X API reads that buy nothing (#299) 2026-08-20 17:58:16 -03:00
ApiKeyController.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
AssetController.php Use whereLike for search so MySQL works alongside PostgreSQL (#302) 2026-08-26 10:59:31 -03:00
AutomationController.php MCP: workspace settings, viewer read access, and token access (#241) 2026-08-06 09:54:51 -03:00
BillingController.php feat: fire signup/checkout PostHog events from the backend (#277) 2026-08-12 11:47:47 -03:00
Controller.php refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
DiscordController.php MCP: workspace settings, viewer read access, and token access (#241) 2026-08-06 09:54:51 -03:00
GiphyController.php feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
LinkPreviewController.php feat(bluesky): add link preview cards for posts 2026-07-17 14:32:40 -03:00
McpSettingsController.php Scope MCP OAuth tokens to user + workspace (#222) (#245) 2026-08-06 21:59:34 -03:00
NotificationController.php refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00
OnboardingController.php Activation checklist + MCP OAuth authorize UX (#239) (#250) 2026-08-07 20:34:43 -03:00
PostAiCreateController.php fix: subscribe to AI generation channel before dispatching the job (#269) 2026-08-10 16:06:37 -03:00
PostAiGenerateController.php fix: subscribe to AI generation channel before dispatching the job (#269) 2026-08-10 16:06:37 -03:00
PostAiRegenerateMediaController.php fix: subscribe to AI generation channel before dispatching the job (#269) 2026-08-10 16:06:37 -03:00
PostAiReviewController.php Fix OpenRouter via laravel/ai default provider (revises #216) (#220) 2026-08-10 21:38:50 -03:00
PostCommentController.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
PostController.php Defuse links in X posts to avoid the link-post fee (#308) 2026-08-29 15:31:05 -03:00
PresenceController.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
UnsplashController.php feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
WelcomeController.php Add social connect step to welcome before Stripe (#293) 2026-08-17 19:37:43 -03:00
WorkspaceController.php Use whereLike for search so MySQL works alongside PostgreSQL (#302) 2026-08-26 10:59:31 -03:00
WorkspaceInviteController.php MCP: workspace settings, viewer read access, and token access (#241) 2026-08-06 09:54:51 -03:00
WorkspaceLabelController.php Use whereLike for search so MySQL works alongside PostgreSQL (#302) 2026-08-26 10:59:31 -03:00
WorkspaceSignatureController.php Use whereLike for search so MySQL works alongside PostgreSQL (#302) 2026-08-26 10:59:31 -03:00