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.

LinkedIn: one comment on a post, through the thread (#475)

Paulo Castellano071df3b26e90
diff --git a/AGENTS.md b/AGENTS.md
index e3c75f5f9..55a578511 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1097,14 +1097,25 @@ an `enabled` flag or posts with several channels. Posts created together share
## Thread replies
-- Bluesky, Mastodon and X (`App\Support\ThreadReplies`), up to 24 replies in `meta.thread_replies`. Each reply is measured against the **account's** limit (`SocialAccount::maxContentLength()`), so an X account with long posts gets 25000 per reply; pass the account to `ThreadReplies::violation()` / `PostPlatformMetaRules::requiredMetaViolation()` whenever it is known.
-- Each reply is `{text, media}`, plus `poll` on an X reply that is a poll (see "X polls") (a stored plain string is a text-only reply; `ThreadReplies::of()` normalizes both, `PostPlatformMetaRules::normalize()` stores objects). Its media belongs to that reply only, never to the root: it publishes as `ThreadReplies::replyContentType()` (X → `XPost`, Bluesky → `BlueskyPost`, Mastodon → `MastodonPost`), so it follows that type's media rules (`ThreadReplies::mediaErrors()`, at save and at publish), and a reply needs text or media. The frontend mirror is `THREAD_REPLY_CONTENT_TYPES`. Adding a network means one entry in each map plus a reply callback in its publisher.
+- Bluesky, Mastodon, X and LinkedIn (`App\Support\ThreadReplies`), in `meta.thread_replies`: up to 24 replies, one on LinkedIn (`ThreadReplies::maxReplies()`, mirrored by `threadMaxReplies()`; see "LinkedIn comment"). Each reply is measured against the **account's** limit (`SocialAccount::maxContentLength()`), so an X account with long posts gets 25000 per reply; pass the account to `ThreadReplies::violation()` / `PostPlatformMetaRules::requiredMetaViolation()` whenever it is known.
+- Each reply is `{text, media}`, plus `poll` on an X reply that is a poll (see "X polls") (a stored plain string is a text-only reply; `ThreadReplies::of()` normalizes both, `PostPlatformMetaRules::normalize()` stores objects). Its media belongs to that reply only, never to the root: it publishes as `ThreadReplies::replyContentType()` (X → `XPost`, Bluesky → `BlueskyPost`, Mastodon → `MastodonPost`, LinkedIn profile and page → `LinkedInComment`), so it follows that type's media rules (`ThreadReplies::mediaErrors()`, at save and at publish), and a reply needs text or media. The frontend mirror is `THREAD_REPLY_CONTENT_TYPES`. Adding a network means one entry in each map plus a reply callback in its publisher.
- Reply media rows are owned by the post like its root media. `SyncOwnedMedia` resolves them from the post's stored `meta.thread_replies` and writes the canonical items back, so write the target's meta **before** calling it; it never deletes a row a reply still uses. Every segment's checkpoint hash covers its media ids.
- In the composer each post of a thread shows its own media under it; the toolbar, paste, drop and the toolbar upload button add to the active post.
- X replies go through `POST /2/tweets` with `reply.in_reply_to_tweet_id` on the previous segment. X restricts API replies (February 2026) to posts whose author summoned the replier; replying to your own post is the case that stays allowed. Each reply is billed as a post.
- Each segment already live is checkpointed in `posts.error_context.thread_progress` (`App\Support\Social\ThreadProgress`), so a retry resumes instead of re-posting, and a resume keeps the root hash. `posts:retry` keeps the live segments.
- `posts.thread_reply_ids` lists the reply ids so `ImportExternalPosts` does not import TryPost's own replies as new posts.
+## LinkedIn comment
+
+A LinkedIn post (profile or page) takes one thread reply, published as a comment from the same profile or page right after the post (#465, owner decision November 2026). There is no "first comment" endpoint or concept of its own: it is the LinkedIn thread, through `ThreadReplies`, `PublishesThreads` and `ThreadProgress` like X, Bluesky and Mastodon. One comment only, so it stays first however the comments are sorted.
+
+- **Reply type:** `ContentType::LinkedInComment` (`linkedin_comment`) is a thread reply's type only: compatible with no platform (`compatiblePlatforms()` is empty), so it is left out of `forPlatform()` and the post type listings and no post is ever stored with it. A comment is **text only** (`maxMediaCount()` 0; the composer turns the media button off with `posts.form.thread.comment_attachments`). The text takes the account's limit (3000), its length error names the comment (`posts.form.thread.comment_too_long`), and it is sent as plain text (a comment's message is not `little`).
+- **Endpoint:** `POST /v2/socialActions/{post URN}/comments` through the publisher's usual client (its `LinkedIn-Version` header is accepted there too). The versioned `/rest/socialActions` needs the Community Management API (403 `partnerApiSocialActions.CREATE`); `/v2/` takes the publish scopes we already hold. Tested on a real page (November 2026): text up to 20000 characters is accepted, a link stays a plain link (LinkedIn draws no card in a comment), and a comment takes one media object at most.
+- **No media (owner decision November 2026):** the API takes an image by URL (`content: [{type: IMAGE, url}]`) and LinkedIn loads it from that URL without copying it, but when LinkedIn cannot fetch the URL it drops the whole comment after answering 201, text included (seen with the `r2.dev` storage URL, while Wikimedia, Giphy and Unsplash URLs stayed). An image uploaded through the Images API (`digitalmediaAsset`), a video and a PDF are accepted but show broken or not at all. Bringing images back needs a URL LinkedIn reliably fetches, tested against the production storage domain.
+- **Failure:** like every thread. The post is checkpointed once it is live, a refused comment fails the publish with `posts.errors.thread_incomplete`, and a retry only comments. A dead token is refreshed once and the thread resumes, never creating the post again.
+- **A post not ready yet:** LinkedIn can answer 404 to a comment sent right after its post (seen on a profile post with an image: "Unable to obtain activity"). A 404 on the comment throws `PlatformUnavailableException` with its own policy (30 seconds, 10 tries), so the job waits in Retrying and resumes from the checkpoint for up to five minutes before failing like any thread.
+- **Composer:** "Add comment" (`posts.form.thread.add_comment`) replaces "Start thread" where replies are comments (`repliesAreComments()`), and the preview shows the comment under the post (`LinkedInPreviewComment`) instead of as a post of its own.
+
## X polls
- A poll is its own content type, `ContentType::XPoll` (`x_poll`), with `meta.poll = {options, duration_minutes}` (owner decision November 2026). `App\Support\Social\XPoll` is the one home for its rules (constants, `limits()`, `options()` / `choices()`, `normalize()`, `violation()`, `optionsCountViolation()`, `choiceLengthViolation()`, `requiredViolation()`, `questionViolation()`, `payload()`, `result()`, `fromPublication()`); `PostPlatformMetaRules`, `PostMeta::forChannel()` / `PostMeta::merge()`, `PostCompositionValidator`, `ContentType::maxContentLengthFor()`, `ThreadReplies` and `XPublisher` call it, never a copy of the numbers or messages. X's `voting_status` values are `App\Enums\X\PollVotingStatus`.
diff --git a/app/Enums/PostPlatform/ContentType.php b/app/Enums/PostPlatform/ContentType.php
index ccb6f1b4e..5e753c811 100644
--- a/app/Enums/PostPlatform/ContentType.php
+++ b/app/Enums/PostPlatform/ContentType.php
@@ -27,6 +27,8 @@ enum ContentType: string
// LinkedIn Page
case LinkedInPagePost = 'linkedin_page_post';
+ case LinkedInComment = 'linkedin_comment';
+
// Facebook
case FacebookPost = 'facebook_post';
case FacebookReel = 'facebook_reel';
@@ -89,6 +91,7 @@ enum ContentType: string
self::InstagramReel => 'Reel',
self::InstagramStory => 'Story',
self::LinkedInPost, self::LinkedInPagePost => 'Post',
+ self::LinkedInComment => 'Comment',
self::FacebookPost => 'Post',
self::FacebookReel => 'Reel',
self::FacebookStory => 'Story',
@@ -124,7 +127,7 @@ enum ContentType: string
{
return match ($this) {
self::InstagramFeed, self::InstagramReel, self::InstagramStory => SocialPlatform::Instagram,
- self::LinkedInPost => SocialPlatform::LinkedIn,
+ self::LinkedInPost, self::LinkedInComment => SocialPlatform::LinkedIn,
self::LinkedInPagePost => SocialPlatform::LinkedInPage,
self::FacebookPost, self::FacebookReel, self::FacebookStory => SocialPlatform::Facebook,
self::TikTokVideo, self::TikTokPhoto => SocialPlatform::TikTok,
@@ -214,6 +217,7 @@ enum ContentType: string
self::InstagramFeed => 10,
self::InstagramReel, self::InstagramStory => 1,
self::LinkedInPost, self::LinkedInPagePost => 10,
+ self::LinkedInComment => 0,
self::FacebookPost => 10,
self::FacebookReel, self::FacebookStory => 1,
self::TikTokVideo => 1,
@@ -488,7 +492,7 @@ enum ContentType: string
self::ThreadsPost, self::ThreadsGhostPost => ['1:1', '4:5', '1.91:1'],
self::BlueskyPost, self::MastodonPost => ['1:1', '16:9'],
self::GoogleBusinessPost => ['4:3', '1:1'],
- self::TelegramPost, self::DiscordMessage => self::defaultCropPresets(),
+ self::TelegramPost, self::DiscordMessage, self::LinkedInComment => self::defaultCropPresets(),
};
}
@@ -683,7 +687,7 @@ enum ContentType: string
'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,
+ 'max_thread_replies' => ThreadReplies::supports($this->platform()) ? ThreadReplies::maxReplies($this->platform()) : null,
];
}
@@ -733,6 +737,7 @@ enum ContentType: string
return match ($this) {
self::InstagramFeed, self::InstagramReel, self::InstagramStory => true,
self::LinkedInPost, self::LinkedInPagePost => true,
+ self::LinkedInComment => false,
self::FacebookPost, self::FacebookReel, self::FacebookStory => true,
self::TikTokVideo => true,
self::TikTokPhoto => false,
@@ -762,6 +767,7 @@ enum ContentType: string
self::ThreadsGhostPost => false,
self::XPoll => false,
self::PinterestVideoPin => false,
+ self::LinkedInComment => false,
default => true,
};
}
@@ -812,7 +818,7 @@ enum ContentType: string
public function requiresMedia(): bool
{
return match ($this) {
- self::LinkedInPost, self::LinkedInPagePost => false,
+ self::LinkedInPost, self::LinkedInPagePost, self::LinkedInComment => false,
self::XPost, self::XPoll => false,
self::ThreadsPost, self::ThreadsGhostPost => false,
self::BlueskyPost => false,
@@ -835,11 +841,10 @@ enum ContentType: string
*/
public function compatiblePlatforms(): array
{
- $primary = $this->platform();
-
- return match ($primary) {
- SocialPlatform::Instagram => [SocialPlatform::Instagram, SocialPlatform::InstagramFacebook],
- default => [$primary],
+ return match (true) {
+ $this === self::LinkedInComment => [],
+ $this->platform() === SocialPlatform::Instagram => [SocialPlatform::Instagram, SocialPlatform::InstagramFacebook],
+ default => [$this->platform()],
};
}
@@ -868,14 +873,9 @@ enum ContentType: string
*/
public static function forPlatform(SocialPlatform $platform): array
{
- $effective = match ($platform) {
- SocialPlatform::InstagramFacebook => SocialPlatform::Instagram,
- default => $platform,
- };
-
return array_filter(
self::cases(),
- fn (self $type) => $type->platform() === $effective
+ fn (self $type) => $type->isCompatibleWith($platform)
);
}
diff --git a/app/Mcp/Servers/TryPostServer.php b/app/Mcp/Servers/TryPostServer.php
index 266e40f2e..810f41f1a 100644
--- a/app/Mcp/Servers/TryPostServer.php
+++ b/app/Mcp/Servers/TryPostServer.php
@@ -98,7 +98,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 (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.')]
+#[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, a thread (X, Bluesky, Mastodon) or one comment (LinkedIn) 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 = 200;
diff --git a/app/Mcp/Tools/Platform/ListContentTypesTool.php b/app/Mcp/Tools/Platform/ListContentTypesTool.php
index c05b4c922..f3f764cd6 100644
--- a/app/Mcp/Tools/Platform/ListContentTypesTool.php
+++ b/app/Mcp/Tools/Platform/ListContentTypesTool.php
@@ -20,7 +20,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(true)]
#[IsDestructive(false)]
#[IsOpenWorld(false)]
-#[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 every post of the platform needs before it is scheduled or published; some needs depend on the content type and are not listed: Google Business events and offers also need meta.event, a YouTube post needs meta.title or text, and an X poll (x_poll) needs meta.poll with at least 2 options and duration_minutes, plus text as its question). 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. The exception is an X poll (content_type x_poll, or a reply in meta.thread_replies with a poll): media, a repeated choice, more than 4 choices, a choice over 25 characters or a duration_minutes outside 5–10080 is refused on every save, drafts included, and the attach media tools refuse it too. 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 (meta.thread_replies: a thread on X, Bluesky or Mastodon, or one comment on LinkedIn). 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 every post of the platform needs before it is scheduled or published; some needs depend on the content type and are not listed: Google Business events and offers also need meta.event, a YouTube post needs meta.title or text, and an X poll (x_poll) needs meta.poll with at least 2 options and duration_minutes, plus text as its question). 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. The exception is an X poll (content_type x_poll, or a reply in meta.thread_replies with a poll): media, a repeated choice, more than 4 choices, a choice over 25 characters or a duration_minutes outside 5–10080 is refused on every save, drafts included, and the attach media tools refuse it too. Call this before attaching media or choosing a content_type.')]
class ListContentTypesTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/CreatePostTool.php b/app/Mcp/Tools/Post/CreatePostTool.php
index 159104c50..25c4ac618 100644
--- a/app/Mcp/Tools/Post/CreatePostTool.php
+++ b/app/Mcp/Tools/Post/CreatePostTool.php
@@ -35,7 +35,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(false)]
#[IsDestructive(true)]
#[IsOpenWorld(true)]
-#[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. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
+#[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. On LinkedIn (profile or page), meta.thread_replies takes one text-only reply, published as a comment from the same author, e.g. [{"text": "Read more: https://..."}]. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
class CreatePostTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/CreatePostsTool.php b/app/Mcp/Tools/Post/CreatePostsTool.php
index 3cb17cefa..6fdb54c88 100644
--- a/app/Mcp/Tools/Post/CreatePostsTool.php
+++ b/app/Mcp/Tools/Post/CreatePostsTool.php
@@ -31,7 +31,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(false)]
#[IsDestructive(true)]
#[IsOpenWorld(true)]
-#[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. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
+#[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. On LinkedIn (profile or page), meta.thread_replies takes one text-only reply, published as a comment from the same author, e.g. [{"text": "Read more: https://..."}]. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
class CreatePostsTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Mcp/Tools/Post/UpdatePostTool.php b/app/Mcp/Tools/Post/UpdatePostTool.php
index 72c417795..2a5f56a37 100644
--- a/app/Mcp/Tools/Post/UpdatePostTool.php
+++ b/app/Mcp/Tools/Post/UpdatePostTool.php
@@ -33,7 +33,7 @@ use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;
#[IsReadOnly(false)]
#[IsDestructive(true)]
#[IsOpenWorld(true)]
-#[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 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. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
+#[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 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. On LinkedIn (profile or page), meta.thread_replies takes one text-only reply, published as a comment from the same author, e.g. [{"text": "Read more: https://..."}]. '.PostPlatformMetaRules::SCHEDULING_REQUIREMENTS)]
class UpdatePostTool extends Tool
{
use AuthorizesMcpTool;
diff --git a/app/Services/Social/AbstractLinkedInPublisher.php b/app/Services/Social/AbstractLinkedInPublisher.php
index bcd42610b..76761f302 100644
--- a/app/Services/Social/AbstractLinkedInPublisher.php
+++ b/app/Services/Social/AbstractLinkedInPublisher.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Services\Social;
+use App\Dto\MediaItem;
use App\Enums\Media\Type as MediaType;
use App\Enums\SocialAccount\Platform;
use App\Exceptions\PlatformUnavailableException;
@@ -15,10 +16,13 @@ use App\Models\SocialAccount;
use App\Services\Http\SafeHttpFetcher;
use App\Services\Media\MediaOptimizer;
use App\Services\Social\Concerns\HasSocialHttpClient;
+use App\Services\Social\Concerns\PublishesThreads;
use App\Services\Social\LinkCard\LinkCardFetcher;
use App\Services\Social\LinkCard\LinkCardMetadata;
+use App\Support\Social\ThreadProgress;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\Response;
+use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@@ -36,6 +40,7 @@ use Throwable;
abstract class AbstractLinkedInPublisher
{
use HasSocialHttpClient;
+ use PublishesThreads;
/** Article title must be under 400 characters, description under 4,086. */
private const int ARTICLE_TITLE_MAX = 399;
@@ -44,6 +49,14 @@ abstract class AbstractLinkedInPublisher
private const int ARTICLE_THUMB_TIMEOUT_SECONDS = 10;
+ /**
+ * LinkedIn answers 404 to a comment on a post it has not finished making
+ * available, so the comment is retried from the queue for up to five minutes.
+ */
+ private const int COMMENT_RETRY_DELAY_SECONDS = 30;
+
+ private const int COMMENT_MAX_RETRIES = 10;
+
/**
* Characters `little` reserves for mentions, hashtags and templates. Any of
* them left unescaped ends the plain text there, so LinkedIn publishes the
@@ -106,14 +119,30 @@ abstract class AbstractLinkedInPublisher
}
$this->accessToken = $this->account->access_token;
+ $rootHash = ThreadProgress::hash((string) $content, $post->mediaItems->map(fn (MediaItem $item): string => $item->id)->all());
try {
- return $this->dispatchByMedia($content, $post);
+ return $this->publishWithComment($post, $content, $rootHash);
} catch (TokenExpiredException $e) {
- return $this->retryWithRefresh($post, $content, $e);
+ return $this->retryWithRefresh($post, $content, $rootHash, $e);
}
}
+ /**
+ * @return array{id: string, url: ?string, thread_reply_ids?: list<string>}
+ */
+ private function publishWithComment(Post $post, ?string $content, string $rootHash): array
+ {
+ return $this->publishThread(
+ $post,
+ $rootHash,
+ fn (): array => $this->dispatchByMedia($content, $post),
+ fn (string $text, Collection $media, array $previous, array $root): array => [
+ 'id' => $this->createComment((string) data_get($root, 'id'), $text),
+ ],
+ );
+ }
+
private function dispatchByMedia(?string $content, Post $post): array
{
$media = $post->mediaItems;
@@ -129,7 +158,7 @@ abstract class AbstractLinkedInPublisher
return $this->publishPost($content, $media, $post->attachesLinkPreview());
}
- private function retryWithRefresh(Post $post, ?string $content, TokenExpiredException $originalException): array
+ private function retryWithRefresh(Post $post, ?string $content, string $rootHash, TokenExpiredException $originalException): array
{
if ($this->hasRetried) {
throw $originalException;
@@ -140,8 +169,6 @@ abstract class AbstractLinkedInPublisher
try {
app(ConnectionVerifier::class)->refreshToken($this->account);
$this->accessToken = $this->account->access_token;
-
- return $this->dispatchByMedia($content, $post);
} catch (Throwable $e) {
Log::error("{$this->label()} refresh failed during retry", [
'account_id' => $this->account->id,
@@ -149,6 +176,8 @@ abstract class AbstractLinkedInPublisher
]);
throw $originalException;
}
+
+ return $this->publishWithComment($post, $content, $rootHash);
}
private function publishPost(?string $content, $media, bool $attachArticle): array
@@ -395,6 +424,44 @@ abstract class AbstractLinkedInPublisher
];
}
+ /**
+ * `/v2/` because the versioned `/rest/socialActions` needs the Community
+ * Management API. Text only: LinkedIn drops the whole comment when it
+ * cannot fetch an image URL.
+ *
+ * @see https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/comments-api
+ */
+ private function createComment(string $postUrn, string $text): string
+ {
+ $response = $this->getHttpClient()->post(
+ "{$this->baseUrl()}/v2/socialActions/".rawurlencode($postUrn).'/comments',
+ [
+ 'actor' => $this->authorUrn(),
+ 'object' => $postUrn,
+ 'message' => ['text' => $text],
+ ],
+ );
+
+ if ($response->notFound()) {
+ throw new PlatformUnavailableException(
+ "{$this->label()} post is not ready for its comment yet",
+ $response->status(),
+ retryDelaySeconds: self::COMMENT_RETRY_DELAY_SECONDS,
+ maxRetries: self::COMMENT_MAX_RETRIES,
+ );
+ }
+
+ if ($response->failed()) {
+ Log::error("{$this->label()} comment creation failed", [
+ 'status' => $response->status(),
+ 'body' => $this->redactResponseBody($response->body()),
+ ]);
+ $this->handleApiError($response);
+ }
+
+ return (string) $response->header('x-restli-id');
+ }
+
/**
* The title shown on a LinkedIn document (PDF carousel) post. Falls back to
* the uploaded file name, then a generic label, so it's never empty.
diff --git a/app/Support/PostPlatformMetaRules.php b/app/Support/PostPlatformMetaRules.php
index 27dddc8c4..d298f6b2c 100644
--- a/app/Support/PostPlatformMetaRules.php
+++ b/app/Support/PostPlatformMetaRules.php
@@ -254,7 +254,7 @@ class PostPlatformMetaRules
public static function documentation(): string
{
return implode(' ', [
- 'Per-platform metadata. A thread on X, Bluesky or Mastodon is meta.thread_replies (see below).',
+ 'Per-platform metadata. A thread on X, Bluesky or Mastodon, or a comment on LinkedIn, 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.',
@@ -267,7 +267,7 @@ class PostPlatformMetaRules
'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: 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). On X a reply may instead be a poll: {text, poll} with poll {options, duration_minutes} under the same rules as meta.poll, no media, and the reply text as its question (required, up to '.XPoll::QUESTION_MAX_LENGTH.' characters).',
+ '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; on LinkedIn (profile and page) a post takes one reply, published as a comment from the same profile or page, text only, up to 3000 characters; 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). On X a reply may instead be a poll: {text, poll} with poll {options, duration_minutes} under the same rules as meta.poll, no media, and the reply text as its question (required, up to '.XPoll::QUESTION_MAX_LENGTH.' characters).',
]);
}
diff --git a/app/Support/ThreadReplies.php b/app/Support/ThreadReplies.php
index 64d65081a..99231a4f1 100644
--- a/app/Support/ThreadReplies.php
+++ b/app/Support/ThreadReplies.php
@@ -40,6 +40,7 @@ class ThreadReplies
Platform::Bluesky => ContentType::BlueskyPost,
Platform::Mastodon => ContentType::MastodonPost,
Platform::X => ContentType::XPost,
+ Platform::LinkedIn, Platform::LinkedInPage => ContentType::LinkedInComment,
default => null,
};
}
@@ -49,6 +50,15 @@ class ThreadReplies
return self::replyContentType($platform) !== null;
}
+ public static function maxReplies(?Platform $platform): int
+ {
+ return match ($platform) {
+ Platform::Bluesky, Platform::Mastodon, Platform::X => self::MAX_REPLIES,
+ Platform::LinkedIn, Platform::LinkedInPage => 1,
+ default => 0,
+ };
+ }
+
/**
* @return list<array{text: string, media: list<array<string, mixed>>, poll?: array{options: list<string>, duration_minutes?: int}}>
*/
@@ -177,6 +187,10 @@ class ThreadReplies
return ['thread_replies', __('posts.form.thread.unsupported')];
}
+ if (count($replies) > self::maxReplies($platform)) {
+ return ['thread_replies', trans_choice('posts.form.thread.too_many', self::maxReplies($platform), ['max' => self::maxReplies($platform)])];
+ }
+
$reserved = $platform->reservedLength(is_array($meta) ? $meta : null);
$account = $target instanceof SocialAccount ? $target : null;
@@ -224,11 +238,15 @@ class ThreadReplies
return self::lengthViolation($reply['text'], $platform, $account, self::replyContentType($platform), $reserved);
}
- if (blank($reply['media'])) {
- return [null, __('posts.form.thread.reply_empty')];
+ if (filled($reply['media'])) {
+ return null;
}
- return null;
+ if (self::replyContentType($platform) === ContentType::LinkedInComment) {
+ return [null, __('posts.form.thread.comment_empty')];
+ }
+
+ return [null, __('posts.form.thread.reply_empty')];
}
/**
@@ -267,6 +285,10 @@ class ThreadReplies
$limit = ContentType::maxContentLengthFor($account, $platform, $type) - $reserved;
+ if ($type === ContentType::LinkedInComment) {
+ return [null, __('posts.form.thread.comment_too_long', ['limit' => $limit, 'over' => $over])];
+ }
+
return [null, __('posts.form.thread.reply_too_long', ['limit' => $limit, 'over' => $over])];
}
diff --git a/lang/ar/posts.php b/lang/ar/posts.php
index cb66b4509..cb5eb9ae1 100644
--- a/lang/ar/posts.php
+++ b/lang/ar/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'سلاسل المنشورات غير متاحة على هذه الشبكة.',
'reply_empty' => 'أحد الردود في السلسلة فارغ.',
'reply_too_long' => 'أحد الردود يتجاوز حد :limit حرفًا بمقدار :over.',
+ 'too_many' => '{1} يقبل هذا المنشور تعليقًا واحدًا فقط.|[0,*] يقبل هذا المنشور حتى :max ردود.',
+ 'add_comment' => 'إضافة تعليق',
+ 'comment_placeholder' => 'أضف رابطًا أو سياقًا إضافيًا',
+ 'comment_label' => 'تعليقك',
+ 'remove_comment' => 'إزالة التعليق',
+ 'comment_too_long' => 'يتجاوز تعليقك حد :limit حرف بمقدار :over.',
+ 'comment_empty' => 'تعليقك فارغ.',
+ 'comment_attachments' => 'لا يمكن أن تتضمن تعليقات LinkedIn وسائط.',
],
'pinterest' => [
diff --git a/lang/de/posts.php b/lang/de/posts.php
index c9c689f14..d8e7f69bc 100644
--- a/lang/de/posts.php
+++ b/lang/de/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Beitragsthreads sind in diesem Netzwerk nicht verfügbar.',
'reply_empty' => 'Eine Antwort im Thread ist leer.',
'reply_too_long' => 'Eine Antwort überschreitet das Limit von :limit Zeichen um :over.',
+ 'too_many' => '{1} Dieser Beitrag nimmt nur einen Kommentar an.|[0,*] Dieser Beitrag nimmt bis zu :max Antworten an.',
+ 'add_comment' => 'Kommentieren',
+ 'comment_placeholder' => 'Füge einen Link oder mehr Kontext hinzu',
+ 'comment_label' => 'Dein Kommentar',
+ 'remove_comment' => 'Kommentar entfernen',
+ 'comment_too_long' => 'Dein Kommentar überschreitet das Limit von :limit Zeichen um :over.',
+ 'comment_empty' => 'Dein Kommentar ist leer.',
+ 'comment_attachments' => 'LinkedIn-Kommentare können keine Medien enthalten.',
],
'pinterest' => [
diff --git a/lang/el/posts.php b/lang/el/posts.php
index d8bc49e5f..68d52a600 100644
--- a/lang/el/posts.php
+++ b/lang/el/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Τα νήματα αναρτήσεων δεν είναι διαθέσιμα σε αυτό το δίκτυο.',
'reply_empty' => 'Μια απάντηση στο νήμα είναι κενή.',
'reply_too_long' => 'Μια απάντηση υπερβαίνει το όριο των :limit χαρακτήρων κατά :over.',
+ 'too_many' => '{1} Αυτή η ανάρτηση δέχεται μόνο ένα σχόλιο.|[0,*] Αυτή η ανάρτηση δέχεται έως :max απαντήσεις.',
+ 'add_comment' => 'Προσθήκη σχολίου',
+ 'comment_placeholder' => 'Προσθέστε έναν σύνδεσμο ή περισσότερο πλαίσιο',
+ 'comment_label' => 'Το σχόλιό σας',
+ 'remove_comment' => 'Αφαίρεση σχολίου',
+ 'comment_too_long' => 'Το σχόλιό σας υπερβαίνει το όριο των :limit χαρακτήρων κατά :over.',
+ 'comment_empty' => 'Το σχόλιό σας είναι κενό.',
+ 'comment_attachments' => 'Τα σχόλια στο LinkedIn δεν μπορούν να περιέχουν πολυμέσα.',
],
'pinterest' => [
diff --git a/lang/en/posts.php b/lang/en/posts.php
index 341214138..7a23c8ad9 100644
--- a/lang/en/posts.php
+++ b/lang/en/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Threads of posts are not available on this network.',
'reply_empty' => 'A reply in the thread is empty.',
'reply_too_long' => 'A reply exceeds the :limit-character limit by :over.',
+ 'too_many' => '{1} Only one comment can follow this post.|[0,*] Up to :max replies can follow this post.',
+ 'add_comment' => 'Add comment',
+ 'comment_placeholder' => 'Add a link or more context',
+ 'comment_label' => 'Your comment',
+ 'remove_comment' => 'Remove comment',
+ 'comment_too_long' => 'Your comment exceeds the :limit-character limit by :over.',
+ 'comment_empty' => 'Your comment is empty.',
+ 'comment_attachments' => 'LinkedIn comments can\'t include media.',
],
'pinterest' => [
diff --git a/lang/es/posts.php b/lang/es/posts.php
index 90853dc58..4bee2ecf6 100644
--- a/lang/es/posts.php
+++ b/lang/es/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Los hilos de publicaciones no están disponibles en esta red.',
'reply_empty' => 'Una respuesta del hilo está vacía.',
'reply_too_long' => 'Una respuesta supera el límite de :limit caracteres en :over.',
+ 'too_many' => '{1} Esta publicación admite solo un comentario.|[0,*] Esta publicación admite hasta :max respuestas.',
+ 'add_comment' => 'Añadir comentario',
+ 'comment_placeholder' => 'Añade un enlace o más contexto',
+ 'comment_label' => 'Tu comentario',
+ 'remove_comment' => 'Quitar comentario',
+ 'comment_too_long' => 'Tu comentario supera el límite de :limit caracteres por :over.',
+ 'comment_empty' => 'Tu comentario está vacío.',
+ 'comment_attachments' => 'Los comentarios de LinkedIn no admiten archivos multimedia.',
],
'pinterest' => [
diff --git a/lang/fr/posts.php b/lang/fr/posts.php
index 81ec70cbc..652dbed4a 100644
--- a/lang/fr/posts.php
+++ b/lang/fr/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Les fils de publications ne sont pas disponibles sur ce réseau.',
'reply_empty' => 'Une réponse du fil est vide.',
'reply_too_long' => 'Une réponse dépasse la limite de :limit caractères de :over.',
+ 'too_many' => '{1} Cette publication n’accepte qu’un commentaire.|[0,*] Cette publication accepte jusqu’à :max réponses.',
+ 'add_comment' => 'Commenter',
+ 'comment_placeholder' => 'Ajoutez un lien ou plus de contexte',
+ 'comment_label' => 'Votre commentaire',
+ 'remove_comment' => 'Retirer le commentaire',
+ 'comment_too_long' => 'Votre commentaire dépasse la limite de :limit caractères de :over.',
+ 'comment_empty' => 'Votre commentaire est vide.',
+ 'comment_attachments' => 'Les commentaires LinkedIn ne peuvent pas contenir de médias.',
],
'pinterest' => [
diff --git a/lang/it/posts.php b/lang/it/posts.php
index dbefb3110..2dcad2943 100644
--- a/lang/it/posts.php
+++ b/lang/it/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'I thread di post non sono disponibili su questa rete.',
'reply_empty' => 'Una risposta del thread è vuota.',
'reply_too_long' => 'Una risposta supera il limite di :limit caratteri di :over.',
+ 'too_many' => '{1} Questo post accetta un solo commento.|[0,*] Questo post accetta fino a :max risposte.',
+ 'add_comment' => 'Aggiungi commento',
+ 'comment_placeholder' => 'Aggiungi un link o più contesto',
+ 'comment_label' => 'Il tuo commento',
+ 'remove_comment' => 'Rimuovi commento',
+ 'comment_too_long' => 'Il tuo commento supera il limite di :limit caratteri di :over.',
+ 'comment_empty' => 'Il tuo commento è vuoto.',
+ 'comment_attachments' => 'I commenti su LinkedIn non possono contenere media.',
],
'pinterest' => [
diff --git a/lang/ja/posts.php b/lang/ja/posts.php
index ca2d6ee63..748223f88 100644
--- a/lang/ja/posts.php
+++ b/lang/ja/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'このネットワークでは投稿のスレッドを利用できません。',
'reply_empty' => 'スレッド内の返信が空です。',
'reply_too_long' => '返信が:limit文字の上限を:over文字超えています。',
+ 'too_many' => '{1} この投稿に追加できるコメントは1件だけです。|[0,*] この投稿には返信を:max件まで追加できます。',
+ 'add_comment' => 'コメントを追加',
+ 'comment_placeholder' => 'リンクや補足を追加',
+ 'comment_label' => 'あなたのコメント',
+ 'remove_comment' => 'コメントを削除',
+ 'comment_too_long' => 'コメントが:limit文字の上限を:over文字超えています。',
+ 'comment_empty' => 'コメントが空です。',
+ 'comment_attachments' => 'LinkedInのコメントにはメディアを添付できません。',
],
'pinterest' => [
diff --git a/lang/ko/posts.php b/lang/ko/posts.php
index f135996c0..6de1ad404 100644
--- a/lang/ko/posts.php
+++ b/lang/ko/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => '이 네트워크에서는 게시물 스레드를 사용할 수 없습니다.',
'reply_empty' => '스레드의 답글이 비어 있습니다.',
'reply_too_long' => '답글이 :limit자 제한을 :over자 초과합니다.',
+ 'too_many' => '{1} 이 게시물에는 댓글을 하나만 달 수 있습니다.|[0,*] 이 게시물에는 답글을 최대 :max개까지 달 수 있습니다.',
+ 'add_comment' => '댓글 추가',
+ 'comment_placeholder' => '링크나 추가 설명을 입력하세요',
+ 'comment_label' => '내 댓글',
+ 'remove_comment' => '댓글 삭제',
+ 'comment_too_long' => '댓글이 :limit자 제한을 :over자 초과했습니다.',
+ 'comment_empty' => '댓글이 비어 있습니다.',
+ 'comment_attachments' => 'LinkedIn 댓글에는 미디어를 첨부할 수 없습니다.',
],
'pinterest' => [
diff --git a/lang/nl/posts.php b/lang/nl/posts.php
index 0fee5cf0d..d8d3a8d8b 100644
--- a/lang/nl/posts.php
+++ b/lang/nl/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Threads van berichten zijn niet beschikbaar op dit netwerk.',
'reply_empty' => 'Een antwoord in de thread is leeg.',
'reply_too_long' => 'Een antwoord overschrijdt de limiet van :limit tekens met :over.',
+ 'too_many' => '{1} Dit bericht neemt maar één reactie.|[0,*] Dit bericht neemt maximaal :max antwoorden.',
+ 'add_comment' => 'Reactie toevoegen',
+ 'comment_placeholder' => 'Voeg een link of meer context toe',
+ 'comment_label' => 'Je reactie',
+ 'remove_comment' => 'Reactie verwijderen',
+ 'comment_too_long' => 'Je reactie overschrijdt de limiet van :limit tekens met :over.',
+ 'comment_empty' => 'Je reactie is leeg.',
+ 'comment_attachments' => 'Reacties op LinkedIn kunnen geen media bevatten.',
],
'pinterest' => [
diff --git a/lang/pl/posts.php b/lang/pl/posts.php
index 5228d1eec..d303d171a 100644
--- a/lang/pl/posts.php
+++ b/lang/pl/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Wątki postów nie są dostępne w tej sieci.',
'reply_empty' => 'Odpowiedź w wątku jest pusta.',
'reply_too_long' => 'Odpowiedź przekracza limit :limit znaków o :over.',
+ 'too_many' => '{1} Ten post przyjmuje tylko jeden komentarz.|[0,*] Ten post przyjmuje maksymalnie :max odpowiedzi.',
+ 'add_comment' => 'Dodaj komentarz',
+ 'comment_placeholder' => 'Dodaj link lub więcej kontekstu',
+ 'comment_label' => 'Twój komentarz',
+ 'remove_comment' => 'Usuń komentarz',
+ 'comment_too_long' => 'Komentarz przekracza limit :limit znaków o :over.',
+ 'comment_empty' => 'Komentarz jest pusty.',
+ 'comment_attachments' => 'Komentarze na LinkedIn nie mogą zawierać multimediów.',
],
'pinterest' => [
diff --git a/lang/pt-BR/posts.php b/lang/pt-BR/posts.php
index 034a63ba0..e7580b9e0 100644
--- a/lang/pt-BR/posts.php
+++ b/lang/pt-BR/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Sequências de posts não estão disponíveis nesta rede.',
'reply_empty' => 'Uma resposta da sequência está vazia.',
'reply_too_long' => 'Uma resposta passa do limite de :limit caracteres em :over.',
+ 'too_many' => '{1} Este post aceita só um comentário.|[0,*] Este post aceita até :max respostas.',
+ 'add_comment' => 'Comentar',
+ 'comment_placeholder' => 'Adicione um link ou mais contexto',
+ 'comment_label' => 'Seu comentário',
+ 'remove_comment' => 'Remover comentário',
+ 'comment_too_long' => 'Seu comentário passa do limite de :limit caracteres em :over.',
+ 'comment_empty' => 'Seu comentário está vazio.',
+ 'comment_attachments' => 'Comentários no LinkedIn não aceitam mídia.',
],
'pinterest' => [
diff --git a/lang/ru/posts.php b/lang/ru/posts.php
index 58998fca7..d482e056c 100644
--- a/lang/ru/posts.php
+++ b/lang/ru/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Цепочки постов недоступны в этой сети.',
'reply_empty' => 'Ответ в цепочке пуст.',
'reply_too_long' => 'Ответ превышает лимит в :limit символов на :over.',
+ 'too_many' => '{1} К этому посту можно добавить только один комментарий.|[0,*] К этому посту можно добавить до :max ответов.',
+ 'add_comment' => 'Комментировать',
+ 'comment_placeholder' => 'Добавьте ссылку или больше контекста',
+ 'comment_label' => 'Ваш комментарий',
+ 'remove_comment' => 'Удалить комментарий',
+ 'comment_too_long' => 'Комментарий превышает лимит в :limit символов на :over.',
+ 'comment_empty' => 'Комментарий пуст.',
+ 'comment_attachments' => 'Комментарии в LinkedIn не могут содержать медиафайлы.',
],
'pinterest' => [
diff --git a/lang/tr/posts.php b/lang/tr/posts.php
index b44663e75..492858198 100644
--- a/lang/tr/posts.php
+++ b/lang/tr/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Gönderi zincirleri bu ağda kullanılamaz.',
'reply_empty' => 'Zincirdeki bir yanıt boş.',
'reply_too_long' => 'Bir yanıt :limit karakter sınırını :over aşıyor.',
+ 'too_many' => '{1} Bu gönderiye yalnızca bir yorum eklenebilir.|[0,*] Bu gönderiye en fazla :max yanıt eklenebilir.',
+ 'add_comment' => 'Yorum ekle',
+ 'comment_placeholder' => 'Bir bağlantı veya daha fazla bağlam ekleyin',
+ 'comment_label' => 'Yorumunuz',
+ 'remove_comment' => 'Yorumu kaldır',
+ 'comment_too_long' => 'Yorumunuz :limit karakter sınırını :over karakter aşıyor.',
+ 'comment_empty' => 'Yorumunuz boş.',
+ 'comment_attachments' => 'LinkedIn yorumları medya içeremez.',
],
'pinterest' => [
diff --git a/lang/uk/posts.php b/lang/uk/posts.php
index 152713511..a32fa654c 100644
--- a/lang/uk/posts.php
+++ b/lang/uk/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => 'Ланцюжки дописів недоступні в цій мережі.',
'reply_empty' => 'Відповідь у ланцюжку порожня.',
'reply_too_long' => 'Відповідь перевищує ліміт у :limit символів на :over.',
+ 'too_many' => '{1} До цього допису можна додати лише один коментар.|[0,*] До цього допису можна додати до :max відповідей.',
+ 'add_comment' => 'Додати коментар',
+ 'comment_placeholder' => 'Додайте посилання або більше контексту',
+ 'comment_label' => 'Ваш коментар',
+ 'remove_comment' => 'Видалити коментар',
+ 'comment_too_long' => 'Коментар перевищує ліміт у :limit символів на :over.',
+ 'comment_empty' => 'Коментар порожній.',
+ 'comment_attachments' => 'Коментарі в LinkedIn не можуть містити медіафайли.',
],
'pinterest' => [
diff --git a/lang/zh/posts.php b/lang/zh/posts.php
index d0a688868..07370d4af 100644
--- a/lang/zh/posts.php
+++ b/lang/zh/posts.php
@@ -492,6 +492,14 @@ return [
'unsupported' => '此网络不支持帖子串。',
'reply_empty' => '帖子串中的一条回复为空。',
'reply_too_long' => '一条回复超出 :limit 字符上限 :over 个字符。',
+ 'too_many' => '{1} 此帖子只能添加一条评论。|[0,*] 此帖子最多可添加 :max 条回复。',
+ 'add_comment' => '添加评论',
+ 'comment_placeholder' => '添加链接或更多背景信息',
+ 'comment_label' => '你的评论',
+ 'remove_comment' => '移除评论',
+ 'comment_too_long' => '你的评论超出 :limit 个字符的限制 :over 个字符。',
+ 'comment_empty' => '你的评论是空的。',
+ 'comment_attachments' => 'LinkedIn 评论不能包含媒体。',
],
'pinterest' => [
diff --git a/resources/js/components/posts/composer/ComposerNetworkCard.vue b/resources/js/components/posts/composer/ComposerNetworkCard.vue
index a7f3238cc..ed91c628b 100644
--- a/resources/js/components/posts/composer/ComposerNetworkCard.vue
+++ b/resources/js/components/posts/composer/ComposerNetworkCard.vue
@@ -5,6 +5,7 @@ import PlatformLogo from '@/components/PlatformLogo.vue';
import ContentTypeRadioGroup from '@/components/posts/editor/ContentTypeRadioGroup.vue';
import type { ContentTypeOption } from '@/composables/usePlatformLogo';
import { autosizeTextarea } from '@/lib/autosizeTextarea';
+import { isShiftEnter } from '@/lib/keyboard';
import {
CAPTIONLESS_CONTENT_TYPES,
MEDIALESS_CONTENT_TYPES,
@@ -97,12 +98,7 @@ const onCaptionKeydown = (event: KeyboardEvent): void => {
return;
}
- if (
- props.threadable &&
- event.key === 'Enter' &&
- event.shiftKey &&
- !event.isComposing
- ) {
+ if (props.threadable && isShiftEnter(event)) {
event.preventDefault();
emit('start-thread');
}
diff --git a/resources/js/components/posts/composer/PostComposerDialog.vue b/resources/js/components/posts/composer/PostComposerDialog.vue
index 1e2f2d6dd..bb4b63d06 100644
--- a/resources/js/components/posts/composer/PostComposerDialog.vue
+++ b/resources/js/components/posts/composer/PostComposerDialog.vue
@@ -174,9 +174,15 @@ import { acceptAttribute, mediaKey } from '@/lib/mediaType';
import { evaluatePlatformMeta } from '@/lib/platformMeta';
import {
newThreadReply,
+ repliesAreComments,
+ replyEmptyKey,
replyErrorOf,
+ replyTooLongKey,
+ startThreadKey,
+ threadMaxReplies,
type ThreadReply,
threadRepliesOf,
+ threadReplyContentType,
} from '@/lib/threadReplies';
import { htmlToPlainText } from '@/lib/utils';
import { pollLimitsOf } from '@/lib/xPoll';
@@ -196,7 +202,6 @@ import {
} from '@/types/content-type';
import type { MediaItem } from '@/types/media';
import {
- THREAD_MAX_REPLIES,
THREAD_PLATFORMS,
THREAD_REPLY_CONTENT_TYPES,
} from '@/types/network-options';
@@ -523,18 +528,14 @@ watch(sharedStep, (shared) => {
});
/** Why the media button is off: a type that takes no media says so, and so does a reply poll. */
const groupMediaDisabledReasonKey = (group: NetworkGroup): string => {
- const reply = activeReply(group);
-
- if (filled(reply) && filled(reply.poll)) {
- return MEDIALESS_CONTENT_TYPE_REASONS[ContentType.XPoll];
- }
-
- if (filled(reply)) {
- return 'posts.composer.media_not_supported';
- }
+ const contentType = transform(
+ activeReply(group),
+ (reply) => threadReplyContentType(group.platform, reply),
+ groupDestination(group).content_type,
+ );
return (
- MEDIALESS_CONTENT_TYPE_REASONS[groupDestination(group).content_type] ??
+ transform(contentType, (type) => MEDIALESS_CONTENT_TYPE_REASONS[type]) ??
'posts.composer.media_not_supported'
);
};
@@ -1177,7 +1178,11 @@ const setThreadReplies = (
};
const addThreadReply = (group: NetworkGroup): void => {
const replies = threadReplies(group);
- if (replies.length >= THREAD_MAX_REPLIES) return;
+
+ if (replies.length >= threadMaxReplies(group.platform)) {
+ return;
+ }
+
setThreadReplies(group, [...replies, newThreadReply()]);
threadActive.value = replies.length;
};
@@ -1186,7 +1191,11 @@ const focusFirstReply = (): void => {
};
const startThreadFromCaption = (group: NetworkGroup): void => {
const replies = threadReplies(group);
- if (replies.length >= THREAD_MAX_REPLIES) return;
+
+ if (replies.length >= threadMaxReplies(group.platform)) {
+ return;
+ }
+
setThreadReplies(group, [newThreadReply(), ...replies]);
threadActive.value = 0;
};
@@ -1351,11 +1360,14 @@ const onMediaFilesSelected = (event: Event): void => {
mediaFileTarget.value.add(files);
}
};
+const replyAcceptsMedia = (platform: string): boolean =>
+ getMediaRulesForContentType(THREAD_REPLY_CONTENT_TYPES[platform]).maxFiles >
+ 0;
const groupAcceptsMedia = (group: NetworkGroup): boolean => {
const reply = activeReply(group);
if (filled(reply)) {
- return reply.poll === undefined;
+ return reply.poll === undefined && replyAcceptsMedia(group.platform);
}
return acceptsMedia(group.key);
@@ -1503,13 +1515,13 @@ const destinationIssues = (account: ComposerAccount): DestinationIssue[] => {
: null;
if (isBlankText(reply.text) && !reply.media.length) {
issues.push({
- key: 'posts.form.thread.reply_empty',
+ key: replyEmptyKey(account.platform),
params: {},
contentType,
});
} else if (over > 0) {
issues.push({
- key: 'posts.form.thread.reply_too_long',
+ key: replyTooLongKey(account.platform),
params: { limit: String(limit), over: String(over) },
contentType,
});
@@ -2745,7 +2757,10 @@ const onDialogOpenChange = (value: boolean): void => {
threadReplies(group)[threadActive] !== undefined
"
:active-reply="threadActive"
- :threadable="supportsThread(group)"
+ :threadable="
+ supportsThread(group) &&
+ !repliesAreComments(group.platform)
+ "
:threaded="threadReplies(group).length > 0"
@expand-caption="deselectThread"
@start-thread="startThreadFromCaption(group)"
@@ -2996,7 +3011,8 @@ const onDialogOpenChange = (value: boolean): void => {
<ThreadRepliesField
v-model:active="threadActive"
:toolbar-target="`composer-${group.anchor.id}-reply-toolbar`"
- :max="THREAD_MAX_REPLIES"
+ :max="threadMaxReplies(group.platform)"
+ :comment="repliesAreComments(group.platform)"
:model-value="threadReplies(group)"
:platform="group.platform"
:limit="threadReplyLimit(group) ?? Infinity"
@@ -3034,9 +3050,10 @@ const onDialogOpenChange = (value: boolean): void => {
/>
<div
v-else-if="
- threadActive === index ||
reply.media.length ||
- replyHasActivity(group, reply)
+ (replyAcceptsMedia(group.platform) &&
+ (threadActive === index ||
+ replyHasActivity(group, reply)))
"
class="flex flex-col gap-2 px-[9px] pt-1"
>
@@ -3151,13 +3168,13 @@ const onDialogOpenChange = (value: boolean): void => {
>
<IconCirclePlus class="size-4" />
<span data-single-line>{{
- $t('posts.form.thread.start')
+ $t(startThreadKey(group.platform))
}}</span>
</Button>
<Tooltip
v-else-if="
threadReplies(group).length <
- THREAD_MAX_REPLIES
+ threadMaxReplies(group.platform)
"
>
<TooltipTrigger as-child>
diff --git a/resources/js/components/posts/editor/ThreadRepliesField.vue b/resources/js/components/posts/editor/ThreadRepliesField.vue
index a6cde387f..898399021 100644
--- a/resources/js/components/posts/editor/ThreadRepliesField.vue
+++ b/resources/js/components/posts/editor/ThreadRepliesField.vue
@@ -1,15 +1,16 @@
<script setup lang="ts">
import { IconX } from '@tabler/icons-vue';
-import { nextTick, ref, watch } from 'vue';
+import { computed, nextTick, ref, watch } from 'vue';
import PlatformLogo from '@/components/PlatformLogo.vue';
import { useXLinkDefuser } from '@/composables/useXLinkDefuser';
import { autosizeTextarea } from '@/lib/autosizeTextarea';
import { displayLength } from '@/lib/characters';
import { filled } from '@/lib/helpers';
+import { isShiftEnter } from '@/lib/keyboard';
import {
isBlankThreadReply,
- newThreadReply,
+ insertThreadReply,
type ThreadReply,
} from '@/lib/threadReplies';
@@ -20,12 +21,19 @@ const props = withDefaults(
/** A reply poll's question cap, kept even on an account with long posts. */
pollLimit?: number;
max?: number;
+ comment?: boolean;
disabled?: boolean;
errors?: Record<number, string>;
/** Id of the element the active post's toolbar is teleported into. */
toolbarTarget?: string;
}>(),
- { pollLimit: Infinity, max: Infinity, disabled: false, errors: () => ({}) },
+ {
+ pollLimit: Infinity,
+ max: Infinity,
+ comment: false,
+ disabled: false,
+ errors: () => ({}),
+ },
);
const replies = defineModel<ThreadReply[]>({ required: true });
@@ -76,6 +84,24 @@ const removeReply = (index: number): void => {
}
};
+const canAddReply = computed(() => replies.value.length < props.max);
+
+const copyKeys = computed(() => {
+ if (props.comment) {
+ return {
+ placeholder: 'posts.form.thread.comment_placeholder',
+ label: 'posts.form.thread.comment_label',
+ remove: 'posts.form.thread.remove_comment',
+ };
+ }
+
+ return {
+ placeholder: 'posts.form.thread.reply_placeholder',
+ label: 'posts.form.thread.reply_label',
+ remove: 'posts.form.thread.remove',
+ };
+});
+
/** Shift+Enter opens the next post right below; Backspace on an empty post folds it back into the one above. */
const onReplyKeydown = (event: KeyboardEvent, index: number): void => {
const textarea = event.target as HTMLTextAreaElement;
@@ -100,18 +126,9 @@ const onReplyKeydown = (event: KeyboardEvent, index: number): void => {
return;
}
- if (event.key === 'Enter' && event.shiftKey && !event.isComposing) {
+ if (isShiftEnter(event) && canAddReply.value) {
event.preventDefault();
-
- if (replies.value.length >= props.max) {
- return;
- }
-
- replies.value = [
- ...replies.value.slice(0, index + 1),
- newThreadReply(),
- ...replies.value.slice(index + 1),
- ];
+ replies.value = insertThreadReply(replies.value, index + 1);
active.value = index + 1;
return;
@@ -171,11 +188,9 @@ watch(
ref="editor"
:value="reply.text"
:data-testid="`thread-reply-${index}`"
- :placeholder="$t('posts.form.thread.reply_placeholder')"
+ :placeholder="$t(copyKeys.placeholder)"
:aria-label="
- $t('posts.form.thread.reply_label', {
- number: String(index + 2),
- })
+ $t(copyKeys.label, { number: String(index + 2) })
"
:aria-invalid="
remaining(reply) < 0 || errors[index] ? true : undefined
@@ -198,7 +213,7 @@ watch(
reply.text ||
(reply.media.length
? ''
- : $t('posts.form.thread.reply_placeholder'))
+ : $t(copyKeys.placeholder))
}}
</button>
<slot name="media" :reply="reply" :index="index" />
@@ -218,7 +233,7 @@ watch(
<button
type="button"
:data-testid="`thread-reply-remove-${index}`"
- :aria-label="$t('posts.form.thread.remove')"
+ :aria-label="$t(copyKeys.remove)"
:disabled="disabled"
class="flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-control hover:bg-accent"
@click="removeReply(index)"
diff --git a/resources/js/components/posts/previews/LinkedInPreview.vue b/resources/js/components/posts/previews/LinkedInPreview.vue
index bf891228a..cd4bff11e 100644
--- a/resources/js/components/posts/previews/LinkedInPreview.vue
+++ b/resources/js/components/posts/previews/LinkedInPreview.vue
@@ -5,13 +5,20 @@ import {
IconSend,
IconThumbUp,
} from '@tabler/icons-vue';
+import { computed } from 'vue';
+import LinkedInPreviewComment from '@/components/posts/previews/LinkedInPreviewComment.vue';
import PreviewTextPost from '@/components/posts/previews/PreviewTextPost.vue';
import type { PreviewProps } from '@/components/posts/previews/types';
import date from '@/date';
+import { filled } from '@/lib/helpers';
+import { threadRepliesOf } from '@/lib/threadReplies';
+const props = defineProps<PreviewProps>();
-defineProps<PreviewProps>();
+const comments = computed(() =>
+ threadRepliesOf(props.meta).filter((reply) => filled(reply.text)),
+);
</script>
<template>
@@ -41,5 +48,15 @@ defineProps<PreviewProps>();
{ icon: IconRepeat, labelKey: 'posts.composer.preview.repost' },
{ icon: IconSend, labelKey: 'posts.composer.preview.send' },
]"
- />
+ >
+ <template v-if="filled(comments)" #after-actions>
+ <LinkedInPreviewComment
+ v-for="(comment, index) in comments"
+ :key="comment.key"
+ :account="socialAccount"
+ :text="comment.text"
+ :data-testid="`preview-comment-${index}`"
+ />
+ </template>
+ </PreviewTextPost>
</template>
diff --git a/resources/js/components/posts/previews/LinkedInPreviewComment.vue b/resources/js/components/posts/previews/LinkedInPreviewComment.vue
new file mode 100644
index 000000000..1b49cc1a0
--- /dev/null
+++ b/resources/js/components/posts/previews/LinkedInPreviewComment.vue
@@ -0,0 +1,25 @@
+<script setup lang="ts">
+import PreviewAvatar from '@/components/posts/previews/PreviewAvatar.vue';
+import type { PreviewAccount } from '@/components/posts/previews/types';
+
+defineProps<{
+ account: PreviewAccount;
+ text: string;
+}>();
+</script>
+
+<template>
+ <div class="flex gap-2 border-t pt-3 pb-1">
+ <PreviewAvatar :account="account" class="size-8 text-[11px]" />
+ <div class="min-w-0 flex-1 rounded-lg bg-muted px-3 py-2">
+ <p class="truncate text-[13px] font-semibold text-foreground">
+ {{ account.display_label }}
+ </p>
+ <p
+ class="text-[13px] break-words whitespace-pre-line text-foreground"
+ >
+ {{ text }}
+ </p>
+ </div>
+ </div>
+</template>
diff --git a/resources/js/components/posts/previews/PlatformPreview.vue b/resources/js/components/posts/previews/PlatformPreview.vue
index 05c233931..9199bbc8a 100644
--- a/resources/js/components/posts/previews/PlatformPreview.vue
+++ b/resources/js/components/posts/previews/PlatformPreview.vue
@@ -20,6 +20,7 @@ import { getPlatformLabel } from '@/composables/usePlatformLogo';
import { useXLinkDefuser } from '@/composables/useXLinkDefuser';
import { filled } from '@/lib/helpers';
import {
+ repliesAreComments,
type ThreadReply,
threadRepliesOf,
threadReplyContentType,
@@ -55,7 +56,7 @@ const { contentFor } = useXLinkDefuser();
const previewContent = computed((): string => contentFor(props.content, props.platform));
const shownReplies = computed((): { reply: ThreadReply; index: number }[] =>
- THREAD_PLATFORMS.includes(props.platform)
+ THREAD_PLATFORMS.includes(props.platform) && !repliesAreComments(props.platform)
? threadRepliesOf(props.meta)
.map((reply, index) => ({ reply, index }))
.filter(
diff --git a/resources/js/components/posts/previews/PreviewTextPost.vue b/resources/js/components/posts/previews/PreviewTextPost.vue
index 823b0a24f..bb9800ca9 100644
--- a/resources/js/components/posts/previews/PreviewTextPost.vue
+++ b/resources/js/components/posts/previews/PreviewTextPost.vue
@@ -319,6 +319,9 @@ const hasActions = computed(
/>
</span>
</div>
+ <div v-if="$slots['after-actions']" :class="{ 'px-4': isStacked }">
+ <slot name="after-actions" />
+ </div>
</div>
</article>
</template>
diff --git a/resources/js/lib/keyboard.ts b/resources/js/lib/keyboard.ts
new file mode 100644
index 000000000..5c8e37ad3
--- /dev/null
+++ b/resources/js/lib/keyboard.ts
@@ -0,0 +1,2 @@
+export const isShiftEnter = (event: KeyboardEvent): boolean =>
+ event.key === 'Enter' && event.shiftKey && !event.isComposing;
diff --git a/resources/js/lib/threadReplies.ts b/resources/js/lib/threadReplies.ts
index 42febafb3..bd784ba2f 100644
--- a/resources/js/lib/threadReplies.ts
+++ b/resources/js/lib/threadReplies.ts
@@ -2,7 +2,10 @@ import { blank, filled, isEmpty } from '@/lib/helpers';
import { uuid } from '@/lib/uuid';
import { ContentType } from '@/types/content-type';
import type { MediaItem } from '@/types/media';
-import { THREAD_REPLY_CONTENT_TYPES } from '@/types/network-options';
+import {
+ THREAD_MAX_REPLIES,
+ THREAD_REPLY_CONTENT_TYPES,
+} from '@/types/network-options';
import type { XPoll } from '@/types/x';
/**
@@ -24,6 +27,11 @@ export const newThreadReply = (): ThreadReply => ({
media: [],
});
+export const insertThreadReply = (
+ replies: ThreadReply[],
+ position: number,
+): ThreadReply[] => replies.toSpliced(position, 0, newThreadReply());
+
/** A reply with nothing in it yet: no text, no media and no poll. */
export const isBlankThreadReply = ({
text,
@@ -85,3 +93,33 @@ export const threadReplyContentType = (
return THREAD_REPLY_CONTENT_TYPES[platform];
};
+
+export const threadMaxReplies = (platform: string): number =>
+ THREAD_MAX_REPLIES[platform] ?? 0;
+
+export const repliesAreComments = (platform: string): boolean =>
+ THREAD_REPLY_CONTENT_TYPES[platform] === ContentType.LinkedInComment;
+
+export const replyTooLongKey = (platform: string): string => {
+ if (repliesAreComments(platform)) {
+ return 'posts.form.thread.comment_too_long';
+ }
+
+ return 'posts.form.thread.reply_too_long';
+};
+
+export const startThreadKey = (platform: string): string => {
+ if (repliesAreComments(platform)) {
+ return 'posts.form.thread.add_comment';
+ }
+
+ return 'posts.form.thread.start';
+};
+
+export const replyEmptyKey = (platform: string): string => {
+ if (repliesAreComments(platform)) {
+ return 'posts.form.thread.comment_empty';
+ }
+
+ return 'posts.form.thread.reply_empty';
+};
diff --git a/resources/js/types/content-type.ts b/resources/js/types/content-type.ts
index e1e8102fb..34fec58d2 100644
--- a/resources/js/types/content-type.ts
+++ b/resources/js/types/content-type.ts
@@ -4,6 +4,7 @@ export const ContentType = {
InstagramReel: 'instagram_reel',
LinkedInPost: 'linkedin_post',
LinkedInPagePost: 'linkedin_page_post',
+ LinkedInComment: 'linkedin_comment',
FacebookPost: 'facebook_post',
FacebookReel: 'facebook_reel',
FacebookStory: 'facebook_story',
@@ -36,6 +37,7 @@ export const CAPTIONLESS_CONTENT_TYPES: ReadonlySet<string> = new Set([
export const MEDIALESS_CONTENT_TYPE_REASONS: Readonly<Record<string, string>> = {
[ContentType.ThreadsGhostPost]: 'posts.form.threads.ghost_post_attachments',
[ContentType.XPoll]: 'posts.form.x.poll.attachments',
+ [ContentType.LinkedInComment]: 'posts.form.thread.comment_attachments',
};
/** Content types that carry no media: the composer hides the media tray. */
diff --git a/resources/js/types/network-options.ts b/resources/js/types/network-options.ts
index 15aa128b0..d48839cb0 100644
--- a/resources/js/types/network-options.ts
+++ b/resources/js/types/network-options.ts
@@ -1,3 +1,5 @@
+import { ContentType } from '@/types/content-type';
+
export const YouTubePrivacyStatus = {
Public: 'public',
Unlisted: 'unlisted',
@@ -12,13 +14,22 @@ export const YouTubeLicense = {
export const YOUTUBE_TITLE_MAX = 100;
export const THREADS_TOPIC_TAG_MAX = 50;
-export const THREAD_MAX_REPLIES = 24;
/** The content type a thread reply publishes as, per network that chains replies. */
export const THREAD_REPLY_CONTENT_TYPES: Readonly<Record<string, string>> = {
- bluesky: 'bluesky_post',
- mastodon: 'mastodon_post',
- x: 'x_post',
+ bluesky: ContentType.BlueskyPost,
+ mastodon: ContentType.MastodonPost,
+ x: ContentType.XPost,
+ linkedin: ContentType.LinkedInComment,
+ 'linkedin-page': ContentType.LinkedInComment,
};
export const THREAD_PLATFORMS: readonly string[] = Object.keys(
THREAD_REPLY_CONTENT_TYPES,
);
+export const THREAD_MAX_REPLIES: Readonly<Record<string, number>> = {
+ bluesky: 24,
+ mastodon: 24,
+ x: 24,
+ linkedin: 1,
+ 'linkedin-page': 1,
+};
+
diff --git a/tests/Browser/ComposerChannelSettingsTest.php b/tests/Browser/ComposerChannelSettingsTest.php
index b8f9a84fc..83f7d73fd 100644
--- a/tests/Browser/ComposerChannelSettingsTest.php
+++ b/tests/Browser/ComposerChannelSettingsTest.php
@@ -1705,3 +1705,26 @@ test('a collaborator link shows the link cursor of a link that opens a new tab',
->and($page->script("document.querySelector('[data-testid=\"instagram-collaborator-alice\"]').target"))->toBe('_blank');
$page->assertNoJavaScriptErrors();
});
+
+test('shift enter in an earlier post of an x thread opens the new post right below it', function () {
+ fakeChannelSettingsApis();
+ $post = seedChannelSettingsPost(Platform::X, ContentType::XPost);
+ $post->update(['content' => 'Root', 'meta' => ['thread_replies' => [['text' => 'Second tweet', 'media' => []], ['text' => 'Third tweet', 'media' => []]]]]);
+ $id = $post->social_account_id;
+
+ $page = visit(route('app.posts.edit', $post))->resize(1440, 1000);
+ waitFor($page, "@composer-caption-{$id}");
+
+ $page->script("(() => { const c = document.querySelector('[data-testid=\"composer-caption-{$id}\"]'); c.focus(); c.setSelectionRange(c.value.length, c.value.length); })()");
+ $page->keys("@composer-caption-{$id}", 'ArrowDown');
+ waitFor($page, '@thread-reply-0');
+
+ $page->keys('@thread-reply-0', 'Shift+Enter');
+ waitFor($page, '@thread-reply-1');
+
+ expect($page->script('document.activeElement?.dataset.testid'))->toBe('thread-reply-1')
+ ->and($page->script("document.querySelector('[data-testid=\"thread-reply-1\"]').value"))->toBe('');
+ $page->assertSeeIn('@thread-reply-collapsed-0', 'Second tweet')
+ ->assertSeeIn('@thread-reply-collapsed-2', 'Third tweet')
+ ->assertNoJavaScriptErrors();
+});
diff --git a/tests/Browser/LinkedInCommentTest.php b/tests/Browser/LinkedInCommentTest.php
new file mode 100644
index 000000000..f3b259f23
--- /dev/null
+++ b/tests/Browser/LinkedInCommentTest.php
@@ -0,0 +1,151 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\PostPlatform\ContentType;
+use App\Models\Post;
+use App\Models\SocialAccount;
+use App\Models\User;
+use App\Models\Workspace;
+use Illuminate\Support\Facades\Http;
+
+function linkedInCommentPost(string $factoryState, ContentType $contentType): Post
+{
+ Http::fake(['*' => Http::response([], 200)]);
+
+ $user = User::factory()->create();
+ $workspace = Workspace::factory()->create(['user_id' => $user->id]);
+ $workspace->members()->attach($user->id, membershipPivot('admin'));
+ $user->update(['current_workspace_id' => $workspace->id]);
+ connectAiTo($user);
+
+ $account = SocialAccount::factory()->{$factoryState}()->create(['workspace_id' => $workspace->id]);
+ $post = Post::factory()->forAccount($account, $contentType)->create([
+ 'user_id' => $user->id,
+ 'content' => 'Our launch is live',
+ ]);
+
+ test()->actingAs($user);
+
+ return $post;
+}
+
+test('a linkedin comment takes no media and the media button says why', function () {
+ $post = linkedInCommentPost('linkedinPage', ContentType::LinkedInPagePost);
+ $id = $post->social_account_id;
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, '@thread-start');
+ $page->click('@thread-start');
+ waitFor($page, '@thread-reply-0');
+ waitFor($page, "@composer-{$id}-media-source-disabled");
+
+ $page->assertMissing("@composer-{$id}-reply-0-dropzone")
+ ->assertMissing("@composer-{$id}-media-source-menu")
+ ->hover("@composer-{$id}-media-source-disabled");
+ waitForText($page, '[data-slot="tooltip-content"]', __('posts.form.thread.comment_attachments'));
+ $page->assertNoJavaScriptErrors();
+});
+
+test('a linkedin post takes one comment that shows under the post in the preview and is kept after saving', function (string $factoryState, ContentType $contentType) {
+ $post = linkedInCommentPost($factoryState, $contentType);
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, '@thread-start');
+ $page->assertSeeIn('@thread-start', __('posts.form.thread.add_comment'))
+ ->click('@thread-start');
+ waitFor($page, '@thread-reply-0');
+
+ $page->fill('@thread-reply-0', 'Read the full story at example.com');
+ waitForText($page, '@preview-comment-0', 'Read the full story at example.com');
+ $page->assertMissing('@thread-add-reply')
+ ->assertMissing('@thread-start')
+ ->assertMissing('@preview-thread-reply-0')
+ ->assertNoJavaScriptErrors();
+
+ $page->click('@composer-save-draft');
+ waitForGone($page, '@post-composer-dialog');
+
+ expect($post->fresh()->meta['thread_replies'])->toEqual([['text' => 'Read the full story at example.com', 'media' => []]]);
+})->with([
+ 'profile' => ['linkedin', ContentType::LinkedInPost],
+ 'page' => ['linkedinPage', ContentType::LinkedInPagePost],
+]);
+
+test('shift enter breaks the line in a linkedin caption and comment instead of opening a thread', function () {
+ $post = linkedInCommentPost('linkedin', ContentType::LinkedInPost);
+ $caption = "@composer-caption-{$post->social_account_id}";
+ $captionHtml = "document.querySelector('[data-testid=\"composer-caption-{$post->social_account_id}\"]').innerHTML";
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, $caption);
+
+ $page->keys($caption, 'End')->keys($caption, 'Shift+Enter');
+ waitForCondition($page, "{$captionHtml}.includes('<br')");
+
+ $page->assertMissing('@thread-reply-0')
+ ->assertPresent('@thread-start')
+ ->click('@thread-start');
+ waitFor($page, '@thread-reply-0');
+
+ $page->fill('@thread-reply-0', 'First line')
+ ->keys('@thread-reply-0', 'Shift+Enter');
+ waitForCondition($page, "document.querySelector('[data-testid=\"thread-reply-0\"]')?.value === 'First line\\n'");
+
+ $page->assertMissing('@thread-reply-1')->assertNoJavaScriptErrors();
+});
+
+test('a linkedin comment over 3000 characters blocks publishing with a comment error', function () {
+ $post = linkedInCommentPost('linkedin', ContentType::LinkedInPost);
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, '@thread-start');
+ $page->click('@thread-start');
+ waitFor($page, '@thread-reply-0');
+
+ $page->fill('@thread-reply-0', str_repeat('a', 3001))
+ ->hover('@composer-submit');
+ waitForText($page, '[data-slot="tooltip-content"]', __('posts.form.thread.comment_too_long', ['limit' => 3000, 'over' => 1]));
+
+ $page->assertNoJavaScriptErrors();
+});
+
+test('a linkedin comment speaks of a comment and removing it brings the add button back', function () {
+ $post = linkedInCommentPost('linkedin', ContentType::LinkedInPost);
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, '@thread-start');
+ $page->click('@thread-start');
+ waitFor($page, '@thread-reply-0');
+
+ $page->assertAttribute('@thread-reply-0', 'placeholder', __('posts.form.thread.comment_placeholder'))
+ ->assertAttribute('@thread-reply-0', 'aria-label', __('posts.form.thread.comment_label'))
+ ->assertAttribute('@thread-reply-remove-0', 'aria-label', __('posts.form.thread.remove_comment'))
+ ->click('@thread-reply-remove-0');
+ waitForGone($page, '@thread-reply-0');
+ waitFor($page, '@thread-start');
+
+ $page->click('@composer-save-draft');
+ waitForGone($page, '@post-composer-dialog');
+
+ expect($post->fresh()->meta)->not->toHaveKey('thread_replies');
+ $page->assertNoJavaScriptErrors();
+});
+
+test('a linkedin post opened with a saved comment shows it as a comment and keeps it on save', function () {
+ $post = linkedInCommentPost('linkedin', ContentType::LinkedInPost);
+ $post->update(['meta' => ['thread_replies' => [['text' => 'Saved comment', 'media' => []]]]]);
+
+ $page = visit(route('app.posts.edit', $post))->resize(1280, 900);
+ waitFor($page, '@preview-comment-0');
+
+ $page->assertSeeIn('@preview-comment-0', 'Saved comment')
+ ->assertMissing('@preview-thread-reply-0')
+ ->assertMissing('@thread-start')
+ ->assertNoJavaScriptErrors();
+
+ $page->click('@composer-save-draft');
+ waitForGone($page, '@post-composer-dialog');
+
+ expect($post->fresh()->meta['thread_replies'])->toEqual([['text' => 'Saved comment', 'media' => []]]);
+});
diff --git a/tests/Feature/Api/PostApiPlatformMetaTest.php b/tests/Feature/Api/PostApiPlatformMetaTest.php
index a297ecdb1..bb223a0e4 100644
--- a/tests/Feature/Api/PostApiPlatformMetaTest.php
+++ b/tests/Feature/Api/PostApiPlatformMetaTest.php
@@ -170,6 +170,42 @@ it('persists the LinkedIn document_title meta on store', function () {
expect(Post::where('social_account_id', $linkedin->id)->sole()->meta['document_title'])->toBe('Q2 Report');
});
+it('stores a LinkedIn comment as the thread reply and refuses a second one when scheduling', function () {
+ $linkedin = SocialAccount::factory()->linkedin()->create(['workspace_id' => $this->workspace->id]);
+ $payload = fn (array $replies) => [
+ 'content' => 'Our launch',
+ 'social_account_id' => $linkedin->id,
+ 'content_type' => ContentType::LinkedInPost->value,
+ 'status' => PostStatus::Scheduled->value,
+ 'scheduled_at' => now()->addDay()->toIso8601String(),
+ 'meta' => ['thread_replies' => $replies],
+ ];
+
+ $this->withHeaders($this->headers)
+ ->postJson(route('api.posts.store'), $payload([['text' => 'Link in the comments', 'media' => []]]))
+ ->assertCreated()
+ ->assertJsonPath('meta.thread_replies.0.text', 'Link in the comments');
+
+ $this->withHeaders($this->headers)
+ ->postJson(route('api.posts.store'), $payload(['First', 'Second']))
+ ->assertUnprocessable()
+ ->assertJsonValidationErrors(['meta.thread_replies']);
+});
+
+it('refuses a post stored as a LinkedIn comment', function () {
+ $linkedin = SocialAccount::factory()->linkedin()->create(['workspace_id' => $this->workspace->id]);
+
+ $this->withHeaders($this->headers)
+ ->postJson(route('api.posts.store'), [
+ 'content' => 'Our launch',
+ 'social_account_id' => $linkedin->id,
+ 'content_type' => ContentType::LinkedInComment->value,
+ ])
+ ->assertUnprocessable();
+
+ expect(Post::query()->count())->toBe(0);
+});
+
it('publishes a LinkedIn document post that has a PDF', function () {
Queue::fake();
diff --git a/tests/Feature/Jobs/PublishToSocialPlatformTest.php b/tests/Feature/Jobs/PublishToSocialPlatformTest.php
index bbc628a8a..457984367 100644
--- a/tests/Feature/Jobs/PublishToSocialPlatformTest.php
+++ b/tests/Feature/Jobs/PublishToSocialPlatformTest.php
@@ -2504,3 +2504,92 @@ test('a post on another network never asks TikTok for a video id', function () {
expect($this->post->fresh()->publish_status)->toBe(PlatformStatus::Published);
Queue::assertNotPushed(ResolveTikTokVideoId::class);
});
+
+test('a linkedin post whose comment fails is marked failed with the thread progress and a retry only comments', function () {
+ Event::fake();
+ Http::fake([
+ config('trypost.platforms.linkedin.api').'/rest/posts' => Http::response(null, 201, ['x-restli-id' => 'urn:li:share:123']),
+ config('trypost.platforms.linkedin.api').'/v2/socialActions/*' => Http::sequence()
+ ->push(['message' => 'Internal error'], 500)
+ ->push([], 201, ['x-restli-id' => '999']),
+ ]);
+ $this->post->forceFill(['meta' => ['thread_replies' => ['Link below']]])->save();
+
+ (new PublishToSocialPlatform($this->post->fresh()))->handle();
+
+ $failed = $this->post->fresh();
+ expect($failed->status)->toBe(PostStatus::Failed)
+ ->and($failed->error_message)->toBe(__('posts.errors.thread_incomplete', [
+ 'published' => 1,
+ 'total' => 2,
+ 'error' => __('posts.errors.linkedin.server_error'),
+ ]));
+
+ $failed->forceFill(['status' => PostStatus::Publishing, 'publish_status' => PlatformStatus::Pending])->save();
+ (new PublishToSocialPlatform($failed->fresh()))->handle();
+
+ $published = $this->post->fresh();
+ expect($published->status)->toBe(PostStatus::Published)
+ ->and($published->platform_post_id)->toBe('urn:li:share:123')
+ ->and($published->thread_reply_ids)->toBe(['999'])
+ ->and(Http::recorded(fn ($request) => str_ends_with($request->url(), '/rest/posts')))->toHaveCount(1);
+});
+
+test('a linkedin comment refused because the post is not ready yet is retried from the queue and only comments', function () {
+ Bus::fake([PublishToSocialPlatform::class]);
+ Event::fake();
+ $now = now()->startOfSecond();
+ Carbon::setTestNow($now);
+ Http::fake([
+ config('trypost.platforms.linkedin.api').'/rest/posts' => Http::response(null, 201, ['x-restli-id' => 'urn:li:share:123']),
+ config('trypost.platforms.linkedin.api').'/v2/socialActions/*' => Http::sequence()
+ ->push(['message' => 'Unable to obtain activity', 'status' => 404], 404)
+ ->push([], 201, ['x-restli-id' => '999']),
+ ]);
+ $this->post->forceFill(['meta' => ['thread_replies' => ['Link below']]])->save();
+
+ (new PublishToSocialPlatform($this->post->fresh()))->handle();
+
+ $waiting = $this->post->fresh();
+ expect($waiting->publish_status)->toBe(PlatformStatus::Retrying)
+ ->and(data_get($waiting->error_context, 'thread_progress.0.id'))->toBe('urn:li:share:123')
+ ->and($waiting->error_context['next_attempt_at'])->toBe($now->copy()->addSeconds(30)->toIso8601String());
+ Bus::assertDispatched(PublishToSocialPlatform::class, fn ($job) => Carbon::instance($job->delay)->equalTo($now->copy()->addSeconds(30)));
+
+ (new PublishToSocialPlatform($waiting))->handle();
+
+ $published = $this->post->fresh();
+ expect($published->status)->toBe(PostStatus::Published)
+ ->and($published->thread_reply_ids)->toBe(['999'])
+ ->and(Http::recorded(fn ($request) => str_ends_with($request->url(), '/rest/posts')))->toHaveCount(1);
+
+ Carbon::setTestNow();
+});
+
+test('a linkedin comment still refused after five minutes fails the publish with the thread progress', function () {
+ Bus::fake([PublishToSocialPlatform::class]);
+ Event::fake();
+ Http::fake([
+ config('trypost.platforms.linkedin.api').'/v2/socialActions/*' => Http::response(['message' => 'Unable to obtain activity', 'status' => 404], 404),
+ ]);
+ $this->post->forceFill([
+ 'meta' => ['thread_replies' => ['Link below']],
+ 'error_context' => [
+ 'thread_progress' => [['hash' => 'stored-root', 'id' => 'urn:li:share:123', 'url' => 'https://www.linkedin.com/feed/update/urn:li:share:123']],
+ 'processing_retry_count' => 10,
+ 'max_retries' => 10,
+ 'retry_delay_seconds' => 30,
+ ],
+ ])->save();
+
+ (new PublishToSocialPlatform($this->post->fresh()))->handle();
+
+ $failed = $this->post->fresh();
+ expect($failed->status)->toBe(PostStatus::Failed)
+ ->and($failed->error_message)->toBe(__('posts.errors.thread_incomplete', [
+ 'published' => 1,
+ 'total' => 2,
+ 'error' => __('posts.errors.platform_unavailable_exhausted'),
+ ]));
+ Bus::assertNotDispatched(PublishToSocialPlatform::class);
+});
diff --git a/tests/Feature/Mcp/MediaFlowTest.php b/tests/Feature/Mcp/MediaFlowTest.php
index 5abfb44ca..66a4861fc 100644
--- a/tests/Feature/Mcp/MediaFlowTest.php
+++ b/tests/Feature/Mcp/MediaFlowTest.php
@@ -404,7 +404,7 @@ test('list-content-types-tool shows every media rule a save enforces', function
$editorOnly = array_flip(['max_files', 'min_files', 'crop_presets', 'platform_label']);
- foreach (ContentType::cases() as $contentType) {
+ foreach (array_filter(ContentType::cases(), fn (ContentType $type): bool => filled($type->compatiblePlatforms())) as $contentType) {
$rules = array_diff_key($contentType->mediaRules(), $editorOnly);
$renamed = ['accept_images', 'accept_videos', 'accept_documents', 'requires_media', 'accepts_gif', 'accepts_mov', 'forbids_mixed_media', 'max_image_bytes', 'max_video_bytes', 'max_document_bytes', 'max_video_duration_sec'];
diff --git a/tests/Feature/Parity/ContentTypesListingParityTest.php b/tests/Feature/Parity/ContentTypesListingParityTest.php
index acdb532b2..68d2791cd 100644
--- a/tests/Feature/Parity/ContentTypesListingParityTest.php
+++ b/tests/Feature/Parity/ContentTypesListingParityTest.php
@@ -61,6 +61,16 @@ test('content types say where thread replies are supported and how many', functi
->toMatchArray(['supports_thread_replies' => false, 'max_thread_replies' => null]);
});
+test('a linkedin post lists one thread reply and the comment type is never listed', function () {
+ $platforms = contentTypesListingApi($this);
+
+ expect(contentTypesListingType($platforms, 'linkedin', 'linkedin_post'))
+ ->toMatchArray(['supports_thread_replies' => true, 'max_thread_replies' => 1])
+ ->and(contentTypesListingType($platforms, 'linkedin-page', 'linkedin_page_post'))
+ ->toMatchArray(['supports_thread_replies' => true, 'max_thread_replies' => 1])
+ ->and(collect($platforms)->pluck('content_types')->flatten(1)->pluck('value'))->not->toContain('linkedin_comment');
+});
+
test('platforms list the meta required to schedule or publish', function () {
$platforms = contentTypesListingApi($this);
diff --git a/tests/Feature/Parity/ThreadsParityTest.php b/tests/Feature/Parity/ThreadsParityTest.php
index 035af6c0d..c8ddd0637 100644
--- a/tests/Feature/Parity/ThreadsParityTest.php
+++ b/tests/Feature/Parity/ThreadsParityTest.php
@@ -13,6 +13,7 @@ use App\Mcp\Tools\Post\UpdatePostTool;
use App\Models\Media;
use App\Models\Post;
use App\Models\SocialAccount;
+use App\Support\ThreadReplies;
use Illuminate\Support\Facades\Storage;
beforeEach(function () {
@@ -226,8 +227,8 @@ test('the batch path rejects 25 replies through api and mcp', function () {
});
test('scheduling replies on a network that cannot chain is rejected through api and mcp', function () {
- $account = threadsParityPlatform(Platform::LinkedIn);
- $destination = ['social_account_id' => $account->id, 'content_type' => ContentType::LinkedInPost->value, 'meta' => ['thread_replies' => ['Two']]];
+ $account = threadsParityPlatform(Platform::Threads);
+ $destination = ['social_account_id' => $account->id, 'content_type' => ContentType::ThreadsPost->value, 'meta' => ['thread_replies' => ['Two']]];
$message = __('posts.form.thread.unsupported');
$response = $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.batch.store'), [
@@ -247,6 +248,27 @@ test('scheduling replies on a network that cannot chain is rejected through api
])->assertHasErrors([$message]);
});
+test('a linkedin post takes one comment and a second one is refused the same way through api and mcp', function () {
+ $account = threadsParityPlatform(Platform::LinkedIn);
+ $payload = fn (array $replies): array => [
+ 'status' => 'scheduled',
+ 'scheduled_at' => now()->addDay()->toIso8601String(),
+ 'content' => 'Root',
+ 'destinations' => [['social_account_id' => $account->id, 'content_type' => ContentType::LinkedInPost->value, 'meta' => ['thread_replies' => $replies]]],
+ ];
+ $message = trans_choice('posts.form.thread.too_many', 1, ['max' => 1]);
+
+ $response = $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.batch.store'), $payload(['Two', 'Three']))->assertUnprocessable();
+ expect(collect($response->json('errors'))->flatten()->implode(' '))->toContain($message);
+ $this->withHeaders(parityApi($this->token))->postJson(route('api.posts.batch.store'), $payload(['Link below']))->assertCreated();
+
+ TryPostServer::actingAs($this->user)->tool(CreatePostsTool::class, $payload(['Two', 'Three']))->assertHasErrors([$message]);
+ TryPostServer::actingAs($this->user)->tool(CreatePostsTool::class, $payload(['Link below']))->assertOk();
+
+ expect(Post::query()->where('social_account_id', $account->id)->get()->map(fn (Post $post): array => ThreadReplies::of($post->meta))->all())
+ ->toBe([[['text' => 'Link below', 'media' => []]], [['text' => 'Link below', 'media' => []]]]);
+});
+
function threadsParityDraft(SocialAccount $account, string $contentType): Post
{
return Post::factory()->forAccount($account, ContentType::from($contentType))->draft()->create(['user_id' => test()->user->id, 'content' => 'Root', 'meta' => []]);
diff --git a/tests/Feature/Services/Social/LinkedInPagePublisherTest.php b/tests/Feature/Services/Social/LinkedInPagePublisherTest.php
index 71985aed1..f6947aeda 100644
--- a/tests/Feature/Services/Social/LinkedInPagePublisherTest.php
+++ b/tests/Feature/Services/Social/LinkedInPagePublisherTest.php
@@ -477,3 +477,22 @@ test('linkedin page publisher sends the article card under the organization', fu
&& $request['content']['article']['source'] === 'https://example.com/article'
&& $request['content']['article']['title'] === 'The Article');
});
+
+test('a linkedin page thread posts its reply as a comment from the organization', function () {
+ Http::fake([
+ config('trypost.platforms.linkedin-page.api').'/rest/posts' => Http::response(null, 201, ['x-restli-id' => 'urn:li:share:123']),
+ config('trypost.platforms.linkedin-page.api').'/v2/socialActions/*' => Http::response([], 201, ['x-restli-id' => '999']),
+ ]);
+ $this->post->update(['meta' => ['thread_replies' => ['Sign up at example.com']]]);
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ $request = Http::recorded(fn ($request) => str_contains($request->url(), '/v2/socialActions/'))->sole()[0];
+ expect($result['thread_reply_ids'])->toBe(['999'])
+ ->and($request->url())->toBe(config('trypost.platforms.linkedin-page.api').'/v2/socialActions/urn%3Ali%3Ashare%3A123/comments')
+ ->and($request->data())->toBe([
+ 'actor' => 'urn:li:organization:123456',
+ 'object' => 'urn:li:share:123',
+ 'message' => ['text' => 'Sign up at example.com'],
+ ]);
+});
diff --git a/tests/Feature/Services/Social/LinkedInPublisherTest.php b/tests/Feature/Services/Social/LinkedInPublisherTest.php
index 22286a1b8..9cf17fb84 100644
--- a/tests/Feature/Services/Social/LinkedInPublisherTest.php
+++ b/tests/Feature/Services/Social/LinkedInPublisherTest.php
@@ -15,6 +15,8 @@ use App\Services\Media\MediaOptimizer;
use App\Services\Social\LinkCard\LinkCardFetcher;
use App\Services\Social\LinkCard\LinkCardMetadata;
use App\Services\Social\LinkedInPublisher;
+use App\Support\Social\ThreadProgress;
+use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Http;
beforeEach(function () {
@@ -1751,3 +1753,161 @@ function linkedInJpegBytes(): string
return $bytes === false ? '' : $bytes;
}
+
+function linkedInCommentFake(array $comment): void
+{
+ Http::fake([
+ config('trypost.platforms.linkedin.api').'/rest/posts' => Http::response(null, 201, ['x-restli-id' => 'urn:li:share:123']),
+ config('trypost.platforms.linkedin.api').'/v2/socialActions/*' => Http::sequence($comment),
+ config('trypost.platforms.linkedin.oauth_api').'/oauth/v2/accessToken' => Http::response([
+ 'access_token' => 'refreshed-token',
+ 'refresh_token' => 'new-refresh-token',
+ 'expires_in' => 5184000,
+ ], 200),
+ ]);
+}
+
+function linkedInCommentRequests(): Collection
+{
+ return Http::recorded(fn ($request) => str_contains($request->url(), '/v2/socialActions/'))->map(fn (array $pair) => $pair[0]);
+}
+
+function linkedInPostRequests(): Collection
+{
+ return Http::recorded(fn ($request) => str_ends_with($request->url(), '/rest/posts'));
+}
+
+test('a linkedin thread posts its reply as a comment from the member on the new post', function () {
+ linkedInCommentFake([Http::response(['id' => '999'], 201, ['x-restli-id' => '999'])]);
+ $this->post->update(['meta' => ['thread_replies' => ['Docs (here) @team #php']]]);
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ expect($result)->toBe([
+ 'id' => 'urn:li:share:123',
+ 'url' => 'https://www.linkedin.com/feed/update/urn:li:share:123',
+ 'thread_reply_ids' => ['999'],
+ ]);
+
+ $request = linkedInCommentRequests()->sole();
+ expect($request->method())->toBe('POST')
+ ->and($request->url())->toBe(config('trypost.platforms.linkedin.api').'/v2/socialActions/urn%3Ali%3Ashare%3A123/comments')
+ ->and($request->header('X-Restli-Protocol-Version'))->toBe(['2.0.0'])
+ ->and($request->data())->toBe([
+ 'actor' => 'urn:li:person:abc123xyz',
+ 'object' => 'urn:li:share:123',
+ 'message' => ['text' => 'Docs (here) @team #php'],
+ ]);
+});
+
+test('a linkedin comment is sent as text only, even when a stored reply still carries media', function () {
+ linkedInCommentFake([Http::response([], 201, ['x-restli-id' => '999'])]);
+ $image = ['id' => 'comment-image', 'path' => 'medias/photo.jpg', 'url' => 'https://example.com/medias/photo.jpg', 'type' => 'image', 'mime_type' => 'image/jpeg', 'original_filename' => 'photo.jpg'];
+ $this->post->update(['meta' => ['thread_replies' => [['text' => 'The chart', 'media' => [$image]]]]]);
+
+ $this->publisher->publish($this->post->fresh());
+
+ expect(linkedInCommentRequests()->sole()->data())->toBe([
+ 'actor' => 'urn:li:person:abc123xyz',
+ 'object' => 'urn:li:share:123',
+ 'message' => ['text' => 'The chart'],
+ ]);
+});
+
+test('a linkedin post without a reply sends no comment request', function () {
+ linkedInCommentFake([Http::response([], 201, ['x-restli-id' => '999'])]);
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ expect($result)->not->toHaveKey('thread_reply_ids')
+ ->and(linkedInCommentRequests())->toBeEmpty();
+});
+
+test('a linkedin thread resumed after the post went live only posts the comment', function () {
+ linkedInCommentFake([Http::response([], 201, ['x-restli-id' => '999'])]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+ $this->post->forceFill(['error_context' => [ThreadProgress::KEY => [
+ ['hash' => 'stored-root', 'id' => 'urn:li:share:123', 'url' => 'https://www.linkedin.com/feed/update/urn:li:share:123'],
+ ]]])->save();
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ expect($result['thread_reply_ids'])->toBe(['999'])
+ ->and(linkedInPostRequests())->toBeEmpty()
+ ->and(linkedInCommentRequests())->toHaveCount(1);
+});
+
+test('a linkedin comment refused after the post went live fails the publish and keeps the post checkpointed', function () {
+ linkedInCommentFake([Http::response(['message' => 'Internal error'], 500)]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+
+ expect(fn () => $this->publisher->publish($this->post->fresh()))->toThrow(LinkedInPublishException::class);
+
+ expect(data_get($this->post->fresh()->error_context, ThreadProgress::KEY.'.0.id'))->toBe('urn:li:share:123')
+ ->and(linkedInPostRequests())->toHaveCount(1);
+});
+
+test('a linkedin token that expires on the comment is refreshed without creating the post again', function () {
+ linkedInCommentFake([
+ Http::response(['code' => 'EXPIRED_ACCESS_TOKEN'], 401),
+ Http::response([], 201, ['x-restli-id' => '999']),
+ ]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ expect($result['thread_reply_ids'])->toBe(['999'])
+ ->and(linkedInPostRequests())->toHaveCount(1)
+ ->and(linkedInCommentRequests())->toHaveCount(2)
+ ->and(linkedInCommentRequests()->last()->header('Authorization'))->toBe(['Bearer refreshed-token']);
+});
+
+test('a linkedin comment refused after a token refresh surfaces the real error, not an expired token', function () {
+ linkedInCommentFake([
+ Http::response(['code' => 'EXPIRED_ACCESS_TOKEN'], 401),
+ Http::response(['message' => 'Internal error'], 500),
+ ]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+
+ expect(fn () => $this->publisher->publish($this->post->fresh()))->toThrow(LinkedInPublishException::class);
+
+ expect(linkedInPostRequests())->toHaveCount(1)
+ ->and(linkedInCommentRequests())->toHaveCount(2);
+});
+
+test('a linkedin token that expires on the post is refreshed and the comment still posts', function () {
+ Http::fake([
+ config('trypost.platforms.linkedin.api').'/rest/posts' => Http::sequence()
+ ->push(['code' => 'EXPIRED_ACCESS_TOKEN'], 401)
+ ->push(null, 201, ['x-restli-id' => 'urn:li:share:123']),
+ config('trypost.platforms.linkedin.api').'/v2/socialActions/*' => Http::response([], 201, ['x-restli-id' => '999']),
+ config('trypost.platforms.linkedin.oauth_api').'/oauth/v2/accessToken' => Http::response([
+ 'access_token' => 'refreshed-token',
+ 'refresh_token' => 'new-refresh-token',
+ 'expires_in' => 5184000,
+ ], 200),
+ ]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+
+ $result = $this->publisher->publish($this->post->fresh());
+
+ expect($result['thread_reply_ids'])->toBe(['999'])
+ ->and(linkedInPostRequests())->toHaveCount(2)
+ ->and(linkedInCommentRequests()->sole()->header('Authorization'))->toBe(['Bearer refreshed-token']);
+});
+
+test('a linkedin post not ready for its comment waits and retries the comment for up to five minutes', function () {
+ linkedInCommentFake([Http::response(['message' => "Unable to obtain activity for urn: 'urn:li:share:123'", 'status' => 404], 404)]);
+ $this->post->update(['meta' => ['thread_replies' => ['Link below']]]);
+
+ try {
+ $this->publisher->publish($this->post->fresh());
+ $this->fail('The comment was not deferred.');
+ } catch (PlatformUnavailableException $e) {
+ expect($e->httpStatus)->toBe(404)
+ ->and($e->retryDelaySeconds)->toBe(30)
+ ->and($e->maxRetries)->toBe(10);
+ }
+
+ expect(data_get($this->post->fresh()->error_context, ThreadProgress::KEY.'.0.id'))->toBe('urn:li:share:123');
+});
diff --git a/tests/Feature/ThreadRepliesPreviewTest.php b/tests/Feature/ThreadRepliesPreviewTest.php
index 4d9d619bc..f5005c7c3 100644
--- a/tests/Feature/ThreadRepliesPreviewTest.php
+++ b/tests/Feature/ThreadRepliesPreviewTest.php
@@ -3,8 +3,10 @@
declare(strict_types=1);
use App\Enums\PostPlatform\ContentType;
+use App\Enums\SocialAccount\Platform;
use App\Models\Post;
use App\Services\Post\PostPreviewer;
+use App\Services\Social\ContentSanitizer;
test('previews thread replies with the network sanitizer', function () {
$post = Post::factory()->bluesky()->create([
@@ -20,6 +22,17 @@ test('previews thread replies with the network sanitizer', function () {
]);
});
+test('a linkedin preview shows its comment with the linkedin sanitizer', function () {
+ $post = Post::factory()->linkedin()->create([
+ 'content' => 'Root',
+ 'meta' => ['thread_replies' => ['<p>Read more at <strong>example.com</strong></p>']],
+ ]);
+
+ expect(app(PostPreviewer::class)->forPost($post->fresh())['thread_replies'])->toEqual([
+ ['text' => app(ContentSanitizer::class)->sanitize('<p>Read more at <strong>example.com</strong></p>', Platform::LinkedIn), 'media' => []],
+ ]);
+});
+
test('networks that cannot chain get no thread preview', function () {
$post = Post::factory()->threads()->create([
'content' => 'Root',
diff --git a/tests/Unit/Enums/ContentTypeTest.php b/tests/Unit/Enums/ContentTypeTest.php
index 52426b08d..79d558a3d 100644
--- a/tests/Unit/Enums/ContentTypeTest.php
+++ b/tests/Unit/Enums/ContentTypeTest.php
@@ -531,6 +531,23 @@ test('a post type is compatible with the platforms it can go to', function () {
->and(ContentType::XPoll->isCompatibleWith(Platform::Bluesky))->toBeFalse();
});
+test('a linkedin comment is a reply type no post can take', function () {
+ expect(ContentType::forPlatform(Platform::LinkedIn))->not->toContain(ContentType::LinkedInComment)
+ ->and(ContentType::forPlatform(Platform::LinkedInPage))->not->toContain(ContentType::LinkedInComment)
+ ->and(ContentType::LinkedInComment->isCompatibleWith(Platform::LinkedIn))->toBeFalse()
+ ->and(ContentType::LinkedInComment->isCompatibleWith(Platform::LinkedInPage))->toBeFalse()
+ ->and(ContentType::LinkedInComment->maxMediaCount())->toBe(0)
+ ->and(ContentType::LinkedInComment->supportsImage())->toBeFalse()
+ ->and(ContentType::LinkedInComment->supportsVideo())->toBeFalse()
+ ->and(ContentType::LinkedInComment->supportsDocument())->toBeFalse()
+ ->and(ContentType::LinkedInComment->requiresMedia())->toBeFalse();
+});
+
+test('an instagram account connected through facebook gets the same post types as instagram', function () {
+ expect(ContentType::forPlatform(Platform::InstagramFacebook))->toBe(ContentType::forPlatform(Platform::Instagram))
+ ->and(array_values(ContentType::forPlatform(Platform::Instagram)))->toBe([ContentType::InstagramFeed, ContentType::InstagramReel, ContentType::InstagramStory]);
+});
+
test('a type without images lists no alt text and a type without video accepts no mov', function (ContentType $type) {
if (! $type->supportsImage()) {
expect($type->supportsAltText())->toBeFalse();
diff --git a/tests/Unit/ThreadRepliesParityTest.php b/tests/Unit/ThreadRepliesParityTest.php
new file mode 100644
index 000000000..fb0058779
--- /dev/null
+++ b/tests/Unit/ThreadRepliesParityTest.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Enums\PostPlatform\ContentType;
+use App\Enums\SocialAccount\Platform;
+use App\Support\ThreadReplies;
+use Symfony\Component\Process\ExecutableFinder;
+use Symfony\Component\Process\Process;
+
+test('the composer threads every network the way the server does', function () {
+ $node = (new ExecutableFinder)->find('node');
+
+ if ($node === null) {
+ test()->markTestSkipped('node is unavailable');
+ }
+
+ $platforms = array_map(fn (Platform $platform): string => $platform->value, Platform::cases());
+ $process = (new Process([$node, base_path('tests/fixtures/thread-replies-harness.ts'), resource_path('js'), ...$platforms]))->mustRun();
+
+ $composer = json_decode($process->getOutput(), true, flags: JSON_THROW_ON_ERROR);
+ $server = collect(Platform::cases())->mapWithKeys(function (Platform $platform): array {
+ $comments = ThreadReplies::replyContentType($platform) === ContentType::LinkedInComment;
+
+ return [$platform->value => [
+ 'reply_content_type' => ThreadReplies::replyContentType($platform)?->value,
+ 'max_replies' => ThreadReplies::maxReplies($platform),
+ 'empty_key' => $comments ? 'posts.form.thread.comment_empty' : 'posts.form.thread.reply_empty',
+ 'too_long_key' => $comments ? 'posts.form.thread.comment_too_long' : 'posts.form.thread.reply_too_long',
+ 'start_key' => $comments ? 'posts.form.thread.add_comment' : 'posts.form.thread.start',
+ ]];
+ })->all();
+
+ expect($composer)->toBe($server);
+});
diff --git a/tests/Unit/ThreadRepliesTest.php b/tests/Unit/ThreadRepliesTest.php
index 0f3fe531c..a978ce864 100644
--- a/tests/Unit/ThreadRepliesTest.php
+++ b/tests/Unit/ThreadRepliesTest.php
@@ -25,8 +25,11 @@ test('thread replies are checked per network', function (Platform $platform, arr
'media-only reply' => [Platform::X, [['text' => '', 'media' => [['id' => 'image']]]], null],
'reply object over the limit' => [Platform::X, [['text' => str_repeat('a', 281), 'media' => [['id' => 'image']]]], 'thread_replies.0'],
'threads cannot chain' => [Platform::Threads, ['second'], 'thread_replies'],
- 'linkedin cannot chain' => [Platform::LinkedIn, ['second'], 'thread_replies'],
- 'empty list ignored' => [Platform::LinkedIn, [], null],
+ 'linkedin comment fits' => [Platform::LinkedIn, [str_repeat('a', 3000)], null],
+ 'linkedin page comment fits' => [Platform::LinkedInPage, ['Link in the comments'], null],
+ 'linkedin comment 3000' => [Platform::LinkedIn, [str_repeat('a', 3001)], 'thread_replies.0'],
+ 'linkedin takes one comment' => [Platform::LinkedIn, ['first', 'second'], 'thread_replies'],
+ 'empty list ignored' => [Platform::Telegram, [], null],
]);
test('a thread violation comes before the network own required meta', function () {
@@ -61,15 +64,43 @@ test('thread_replies has a rule so validated() keeps it', function () {
->and(ThreadReplies::supports(Platform::X))->toBeTrue()
->and(ThreadReplies::supports(Platform::Mastodon))->toBeTrue()
->and(ThreadReplies::supports(Platform::Bluesky))->toBeTrue()
+ ->and(ThreadReplies::supports(Platform::LinkedIn))->toBeTrue()
+ ->and(ThreadReplies::supports(Platform::LinkedInPage))->toBeTrue()
->and(ThreadReplies::supports(Platform::Threads))->toBeFalse();
});
+test('a linkedin post takes one comment while the other threads take up to 24 replies', function () {
+ expect(ThreadReplies::maxReplies(Platform::LinkedIn))->toBe(1)
+ ->and(ThreadReplies::maxReplies(Platform::LinkedInPage))->toBe(1)
+ ->and(ThreadReplies::maxReplies(Platform::X))->toBe(24)
+ ->and(ThreadReplies::maxReplies(Platform::Threads))->toBe(0)
+ ->and(PostPlatformMetaRules::requiredMetaViolation(Platform::LinkedIn, ['thread_replies' => ['first', 'second']]))
+ ->toBe(['thread_replies', trans_choice('posts.form.thread.too_many', 1, ['max' => 1])]);
+});
+
+test('a linkedin comment takes no media and its length and empty errors name the comment', function () {
+ $image = ['id' => 'image', 'type' => 'image', 'mime_type' => 'image/jpeg'];
+
+ expect(ThreadReplies::mediaErrors(Platform::LinkedIn, ['thread_replies' => [['text' => 'Link below', 'media' => [$image]]]], null))
+ ->toBe(['thread_replies.0.media' => __('posts.form.warnings.max_files_exceeded', ['max' => 0, 'current' => 1])])
+ ->and(PostPlatformMetaRules::requiredMetaViolation(Platform::LinkedIn, ['thread_replies' => [str_repeat('a', 3001)]]))
+ ->toBe(['thread_replies.0', __('posts.form.thread.comment_too_long', ['limit' => 3000, 'over' => 1])])
+ ->and(PostPlatformMetaRules::requiredMetaViolation(Platform::X, ['thread_replies' => [str_repeat('a', 281)]]))
+ ->toBe(['thread_replies.0', __('posts.form.thread.reply_too_long', ['limit' => 280, 'over' => 1])])
+ ->and(PostPlatformMetaRules::requiredMetaViolation(Platform::LinkedIn, ['thread_replies' => [' ']]))
+ ->toBe(['thread_replies.0', __('posts.form.thread.comment_empty')])
+ ->and(PostPlatformMetaRules::requiredMetaViolation(Platform::X, ['thread_replies' => [' ']]))
+ ->toBe(['thread_replies.0', __('posts.form.thread.reply_empty')]);
+});
+
test('a reply publishes as its network post type and takes that type media rules', function () {
$image = ['id' => 'image', 'type' => 'image', 'mime_type' => 'image/jpeg'];
expect(ThreadReplies::replyContentType(Platform::X))->toBe(ContentType::XPost)
->and(ThreadReplies::replyContentType(Platform::Bluesky))->toBe(ContentType::BlueskyPost)
->and(ThreadReplies::replyContentType(Platform::Mastodon))->toBe(ContentType::MastodonPost)
+ ->and(ThreadReplies::replyContentType(Platform::LinkedIn))->toBe(ContentType::LinkedInComment)
+ ->and(ThreadReplies::replyContentType(Platform::LinkedInPage))->toBe(ContentType::LinkedInComment)
->and(ThreadReplies::replyContentType(Platform::Threads))->toBeNull()
->and(ThreadReplies::of(['thread_replies' => ['Two', ['text' => 'Three', 'media' => [$image]]]]))->toBe([
['text' => 'Two', 'media' => []],
diff --git a/tests/fixtures/single-line-copy.php b/tests/fixtures/single-line-copy.php
index dcf36431a..8b66dcd9f 100644
--- a/tests/fixtures/single-line-copy.php
+++ b/tests/fixtures/single-line-copy.php
@@ -144,6 +144,7 @@ return [
'posts.form.instagram.trial_reel.not_checked' => 5,
'posts.form.instagram.trial_reel.off' => 6,
'posts.form.mastodon.content_warning' => 20,
+ 'posts.form.thread.add_comment' => 17,
'posts.form.thread.start' => 17,
'posts.form.threads.topic' => 9,
'posts.form.tiktok.privacy_level' => 13,
diff --git a/tests/fixtures/thread-replies-harness.ts b/tests/fixtures/thread-replies-harness.ts
new file mode 100644
index 000000000..a0ed460c4
--- /dev/null
+++ b/tests/fixtures/thread-replies-harness.ts
@@ -0,0 +1,42 @@
+/**
+ * Prints what the composer's thread helpers (`lib/threadReplies.ts`) answer for
+ * each platform given as an argument, so `ThreadRepliesParityTest.php` can
+ * compare them with `ThreadReplies` on the server.
+ *
+ * Node strips type annotations on import; the resolve hook maps the `@/` alias
+ * and extension-less specifiers onto `resources/js/**.ts`.
+ */
+import { registerHooks } from 'node:module';
+import path from 'node:path';
+import { pathToFileURL } from 'node:url';
+
+const [resourcesDir, ...platforms] = process.argv.slice(2);
+
+registerHooks({
+ resolve: (specifier, context, nextResolve) =>
+ specifier.startsWith('@/')
+ ? nextResolve(pathToFileURL(path.join(path.resolve(resourcesDir), `${specifier.slice(2)}.ts`)).href, context)
+ : nextResolve(specifier, context),
+});
+
+const { replyEmptyKey, replyTooLongKey, startThreadKey, threadMaxReplies } = await import(
+ pathToFileURL(path.join(path.resolve(resourcesDir), 'lib/threadReplies.ts')).href
+);
+const { THREAD_REPLY_CONTENT_TYPES } = await import(
+ pathToFileURL(path.join(path.resolve(resourcesDir), 'types/network-options.ts')).href
+);
+
+const results = Object.fromEntries(
+ platforms.map((platform) => [
+ platform,
+ {
+ reply_content_type: THREAD_REPLY_CONTENT_TYPES[platform] ?? null,
+ max_replies: threadMaxReplies(platform),
+ empty_key: replyEmptyKey(platform),
+ too_long_key: replyTooLongKey(platform),
+ start_key: startThreadKey(platform),
+ },
+ ]),
+);
+
+console.log(JSON.stringify(results));