Add optional Pinterest pin title and destination link (#232)

* Add optional Pinterest pin title, description, and link.

Expose title/description/link across web, API, and MCP; seed description from caption into meta on save, and publish description only from meta.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Expand Pinterest title/description/link test coverage.

Cover web draft persistence and validation bounds, API/MCP update merge and seed, and publisher payload fields on video and carousel pins.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Simplify Pinterest: description is post content again.

Keep optional title and link in meta/settings only. Remove the separate description textarea, seed logic, and meta.description path so Pinterest follows the shared caption pattern.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Refactor Pinterest meta handling and validation.

- Update CreatePost and UpdatePost actions to filter out null values from meta fields.
- Introduce a new method in PinterestPublisher to resolve board IDs, ensuring required fields are validated.
- Enhance PinterestSettings component to manage title and link inputs, including validation for HTTP URLs.
- Update PostPlatformMetaRules to enforce URL validation for Pinterest links.
- Add tests for clearing Pinterest title and link, and for rejecting invalid links during scheduling.

This refactor improves the handling of Pinterest metadata and enhances user experience by ensuring proper validation and error handling.

* Add validation messages and attributes for Pinterest meta fields

- Introduced custom validation messages and friendly attribute names for Pinterest link and title fields in PostPlatformMetaRules.
- Updated StorePostRequest, UpdatePostRequest, and related tools to utilize these new messages and attributes.
- Enhanced tests to assert correct error messages for invalid Pinterest links and title length constraints.

This update improves user feedback during post creation and editing, ensuring clarity in validation errors.

* Remove click.prevent directive from Pinterest link in PinterestPreview component.

This change simplifies the link behavior, allowing default click actions to occur, which may enhance user interaction with the Pinterest link.

* Update validation error messages for Pinterest meta fields in tests

- Refined the assertions in PostApiPlatformMetaTest to include localized validation messages for Pinterest title and link fields.
- Ensured that error messages reflect the updated validation rules, enhancing clarity for users during post creation and editing.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Paulo Castellano 2026-08-05 17:15:50 -04:00 committed by GitHub
parent 4679ef79c1
commit 2248d01edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 988 additions and 168 deletions

View file

@ -74,7 +74,10 @@ public static function execute(Workspace $workspace, User $user, array $data): P
->first();
if ($existing) {
$updates['meta'] = array_merge($existing->meta ?? [], $meta);
$updates['meta'] = array_filter(
array_merge($existing->meta ?? [], $meta),
fn (mixed $value): bool => $value !== null,
);
}
}

View file

@ -58,7 +58,10 @@ public static function execute(Workspace $workspace, Post $post, array $data): a
$postPlatform = $post->postPlatforms()->where('id', data_get($platformData, 'id'))->first();
if ($postPlatform) {
$updateData['meta'] = array_merge($postPlatform->meta ?? [], data_get($platformData, 'meta'));
$updateData['meta'] = array_filter(
array_merge($postPlatform->meta ?? [], data_get($platformData, 'meta') ?? []),
fn (mixed $value): bool => $value !== null,
);
}
}

View file

@ -61,6 +61,22 @@ public function rules(): array
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return PostPlatformMetaRules::messages();
}
/**
* @return array<string, string>
*/
public function attributes(): array
{
return PostPlatformMetaRules::attributes();
}
/**
* @return Collection<int, Platform>
*/

View file

@ -64,6 +64,22 @@ public function rules(): array
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return PostPlatformMetaRules::messages();
}
/**
* @return array<string, string>
*/
public function attributes(): array
{
return PostPlatformMetaRules::attributes();
}
public function withValidator(Validator $validator): void
{
$validator->after(function (Validator $validator): void {

View file

@ -61,6 +61,22 @@ public function rules(): array
];
}
/**
* @return array<string, string>
*/
public function messages(): array
{
return PostPlatformMetaRules::messages();
}
/**
* @return array<string, string>
*/
public function attributes(): array
{
return PostPlatformMetaRules::attributes();
}
public function withValidator(Validator $validator): void
{
$validator->after(function (Validator $validator): void {

View file

@ -25,22 +25,26 @@ public function handle(Request $request): ResponseFactory
{
$workspace = $request->user()->currentWorkspace;
$validated = $request->validate([
'content' => ['nullable', 'string', 'max:10000'],
'scheduled_at' => ['nullable', 'date', 'after:now'],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)],
'platforms' => ['sometimes', 'array'],
'platforms.*.social_account_id' => [
'required',
'uuid',
Rule::exists('social_accounts', 'id')
->where('workspace_id', $workspace->id)
->where('is_active', true),
$validated = $request->validate(
[
'content' => ['nullable', 'string', 'max:10000'],
'scheduled_at' => ['nullable', 'date', 'after:now'],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)],
'platforms' => ['sometimes', 'array'],
'platforms.*.social_account_id' => [
'required',
'uuid',
Rule::exists('social_accounts', 'id')
->where('workspace_id', $workspace->id)
->where('is_active', true),
],
'platforms.*.content_type' => ['required', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPlatform],
...PostPlatformMetaRules::rules(),
],
'platforms.*.content_type' => ['required', 'string', Rule::in(array_column(ContentType::cases(), 'value')), new ContentTypeMatchesPlatform],
...PostPlatformMetaRules::rules(),
]);
PostPlatformMetaRules::messages(),
PostPlatformMetaRules::attributes(),
);
$validated['created_via'] = CreatedVia::Mcp;
@ -63,7 +67,7 @@ public function schema(JsonSchema $schema): array
->items($schema->object(fn ($p) => [
'social_account_id' => $p->string()->required()->description('UUID of the connected social account.'),
'content_type' => $p->string()->required()->description('Format for this platform (e.g. linkedin_post, x_post, instagram_feed).'),
'meta' => $p->object()->description('Per-platform metadata. Instagram/Facebook: aspect_ratio (1:1|4:5|16:9|original). TikTok: privacy_level (required to publish) + flags (allow_comments, allow_duet, allow_stitch, disclose, brand_content_toggle, brand_organic_toggle, is_aigc, auto_add_music). Pinterest: board_id (required to publish — call ListPinterestBoardsTool first). Discord: channel_id (required to publish — call ListDiscordChannelsTool first), mentions ([{token,label}]), embeds ([{title,description,url,image,color}]).'),
'meta' => $p->object()->description('Per-platform metadata. Instagram/Facebook: aspect_ratio (1:1|4:5|16:9|original). TikTok: privacy_level (required to publish) + flags (allow_comments, allow_duet, allow_stitch, disclose, brand_content_toggle, brand_organic_toggle, is_aigc, auto_add_music). Pinterest: board_id (required to publish — call ListPinterestBoardsTool first), title (≤100), link (destination URL). Pin description comes from the post content. Discord: channel_id (required to publish — call ListDiscordChannelsTool first), mentions ([{token,label}]), embeds ([{title,description,url,image,color}]).'),
]))
->description('Platforms to publish on. Accounts not listed remain available but disabled.'),
];

View file

@ -39,27 +39,31 @@ public function handle(Request $request): Response|ResponseFactory
$status = data_get($request->all(), 'status');
$validated = $request->validate([
'post_id' => ['required', 'uuid'],
'content' => ['nullable', 'string', 'max:10000'],
'scheduled_at' => PostStatusRules::scheduledAtRules($post, $status),
'status' => ['sometimes', 'string', Rule::in([Status::Draft->value, Status::Scheduled->value])],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)],
'platforms' => ['sometimes', 'array'],
'platforms.*.id' => [
'required',
'uuid',
Rule::exists('post_platforms', 'id')->where('post_id', $post->id),
$validated = $request->validate(
[
'post_id' => ['required', 'uuid'],
'content' => ['nullable', 'string', 'max:10000'],
'scheduled_at' => PostStatusRules::scheduledAtRules($post, $status),
'status' => ['sometimes', 'string', Rule::in([Status::Draft->value, Status::Scheduled->value])],
'label_ids' => ['sometimes', 'array'],
'label_ids.*' => ['uuid', Rule::exists('workspace_labels', 'id')->where('workspace_id', $workspace->id)],
'platforms' => ['sometimes', 'array'],
'platforms.*.id' => [
'required',
'uuid',
Rule::exists('post_platforms', 'id')->where('post_id', $post->id),
],
'platforms.*.content_type' => [
'sometimes',
'string',
Rule::in(array_column(ContentType::cases(), 'value')),
new ContentTypeMatchesPostPlatform,
],
...PostPlatformMetaRules::rules(),
],
'platforms.*.content_type' => [
'sometimes',
'string',
Rule::in(array_column(ContentType::cases(), 'value')),
new ContentTypeMatchesPostPlatform,
],
...PostPlatformMetaRules::rules(),
]);
PostPlatformMetaRules::messages(),
PostPlatformMetaRules::attributes(),
);
// On schedule, validate each platform's effective content_type (resubmitted
// here, or stored) against the post's stored media — the tool can't change
@ -107,7 +111,7 @@ public function schema(JsonSchema $schema): array
->items($schema->object(fn ($p) => [
'id' => $p->string()->required()->description('UUID of the post_platform row (from get-post-tool / list-posts-tool).'),
'content_type' => $p->string()->description('New content_type for this platform.'),
'meta' => $p->object()->description('Per-platform metadata override. Instagram/Facebook: aspect_ratio. TikTok: privacy_level (required to publish) + flags. Pinterest: board_id (required to publish — call ListPinterestBoardsTool first). Discord: channel_id (required to publish — call ListDiscordChannelsTool first), mentions, embeds. Merged with existing meta.'),
'meta' => $p->object()->description('Per-platform metadata override. Instagram/Facebook: aspect_ratio. TikTok: privacy_level (required to publish) + flags. Pinterest: board_id (required to publish — call ListPinterestBoardsTool first), title (≤100), link (destination URL). Pin description comes from the post content. Discord: channel_id (required to publish — call ListDiscordChannelsTool first), mentions, embeds. Merged with existing meta.'),
]))
->description('Platforms to enable for publishing. Any platform NOT listed will be disabled. Pass an empty array to disable all.'),
];

View file

@ -38,7 +38,9 @@ public function publish(PostPlatform $postPlatform): array
app(ConnectionVerifier::class)->refreshToken($account);
}
$content = $postPlatform->post->content ? app(ContentSanitizer::class)->sanitize($postPlatform->post->content, $postPlatform->platform) : null;
$content = $postPlatform->post->content
? app(ContentSanitizer::class)->sanitize($postPlatform->post->content, $postPlatform->platform)
: null;
return match ($postPlatform->content_type) {
ContentType::PinterestPin => $this->publishImagePin($postPlatform, $content),
@ -51,6 +53,69 @@ public function publish(PostPlatform $postPlatform): array
};
}
/**
* Apply pin description from the shared post caption, plus optional title/link from meta.
*
* @param array<string, mixed> $payload
* @return array<string, mixed>
*/
private function applyPinTextFields(array $payload, PostPlatform $postPlatform, ?string $content): array
{
if (filled($content)) {
$payload['description'] = mb_substr($content, 0, 800);
}
if (filled(data_get($postPlatform->meta, 'title'))) {
$payload['title'] = mb_substr((string) data_get($postPlatform->meta, 'title'), 0, 100);
}
if (filled(data_get($postPlatform->meta, 'link'))) {
$payload['link'] = data_get($postPlatform->meta, 'link');
}
return $payload;
}
private function resolveBoardId(PostPlatform $postPlatform): string
{
$boardId = data_get($postPlatform->meta, 'board_id')
?? data_get($postPlatform->socialAccount->meta, 'default_board_id');
if (! filled($boardId)) {
throw new PinterestPublishException(
userMessage: 'Pinterest board_id is required',
category: ErrorCategory::ContentPolicy,
);
}
return (string) $boardId;
}
/**
* @param array<string, mixed> $payload
* @return array{id: mixed, url: string}
*/
private function createPin(SocialAccount $account, array $payload, string $failureLogMessage): array
{
$response = $this->socialHttp()->withToken($account->access_token)
->post($this->baseUrl.'/pins', $payload);
if ($response->failed()) {
Log::error($failureLogMessage, [
'status' => $response->status(),
'body' => $this->redactResponseBody($response->body()),
]);
$this->handleApiError($response);
}
$pinId = data_get($response->json(), 'id');
return [
'id' => $pinId,
'url' => "https://pinterest.com/pin/{$pinId}",
];
}
private function publishImagePin(PostPlatform $postPlatform, ?string $content): array
{
$account = $postPlatform->socialAccount;
@ -63,14 +128,7 @@ private function publishImagePin(PostPlatform $postPlatform, ?string $content):
);
}
$boardId = data_get($postPlatform->meta, 'board_id') ?? data_get($account->meta, 'default_board_id') ?? null;
if (! $boardId) {
throw new PinterestPublishException(
userMessage: 'Pinterest board_id is required',
category: ErrorCategory::ContentPolicy,
);
}
$boardId = $this->resolveBoardId($postPlatform);
// Download and optimize image
$tempFile = tempnam(sys_get_temp_dir(), 'pin_image_');
@ -98,26 +156,14 @@ private function publishImagePin(PostPlatform $postPlatform, ?string $content):
@unlink($tempFile);
}
$payload = [
$payload = $this->applyPinTextFields([
'board_id' => $boardId,
'media_source' => [
'source_type' => 'image_base64',
'content_type' => 'image/jpeg',
'data' => $imageBase64,
],
];
if ($content) {
$payload['description'] = $content;
}
if (! empty(data_get($postPlatform->meta, 'title'))) {
$payload['title'] = substr(data_get($postPlatform->meta, 'title'), 0, 100);
}
if (! empty(data_get($postPlatform->meta, 'link'))) {
$payload['link'] = data_get($postPlatform->meta, 'link');
}
], $postPlatform, $content);
$alt = $postPlatform->post->mediaItems->first(fn ($m) => $m->isImage())?->altTextFor(Platform::Pinterest);
@ -125,23 +171,7 @@ private function publishImagePin(PostPlatform $postPlatform, ?string $content):
$payload['alt_text'] = $alt;
}
$response = $this->socialHttp()->withToken($account->access_token)
->post($this->baseUrl.'/pins', $payload);
if ($response->failed()) {
Log::error('Pinterest pin creation failed', [
'status' => $response->status(),
'body' => $this->redactResponseBody($response->body()),
]);
$this->handleApiError($response);
}
$data = $response->json();
return [
'id' => data_get($data, 'id'),
'url' => 'https://pinterest.com/pin/'.data_get($data, 'id'),
];
return $this->createPin($account, $payload, 'Pinterest pin creation failed');
}
private function publishVideoPin(PostPlatform $postPlatform, ?string $content): array
@ -156,14 +186,7 @@ private function publishVideoPin(PostPlatform $postPlatform, ?string $content):
);
}
$boardId = data_get($postPlatform->meta, 'board_id') ?? data_get($account->meta, 'default_board_id') ?? null;
if (! $boardId) {
throw new PinterestPublishException(
userMessage: 'Pinterest board_id is required',
category: ErrorCategory::ContentPolicy,
);
}
$boardId = $this->resolveBoardId($postPlatform);
// Step 1: Register media upload
$registerResponse = $this->socialHttp()->withToken($account->access_token)
@ -253,25 +276,13 @@ private function publishVideoPin(PostPlatform $postPlatform, ?string $content):
$this->waitForMediaProcessing($account, $mediaId);
// Step 4: Create pin with video
$payload = [
$payload = $this->applyPinTextFields([
'board_id' => $boardId,
'media_source' => [
'source_type' => 'video_id',
'media_id' => $mediaId,
],
];
if ($content) {
$payload['description'] = $content;
}
if (! empty(data_get($postPlatform->meta, 'title'))) {
$payload['title'] = substr(data_get($postPlatform->meta, 'title'), 0, 100);
}
if (! empty(data_get($postPlatform->meta, 'link'))) {
$payload['link'] = data_get($postPlatform->meta, 'link');
}
], $postPlatform, $content);
if (! empty(data_get($postPlatform->meta, 'cover_image_url'))) {
$payload['media_source']['cover_image_url'] = data_get($postPlatform->meta, 'cover_image_url');
@ -279,23 +290,7 @@ private function publishVideoPin(PostPlatform $postPlatform, ?string $content):
$payload['media_source']['cover_image_key_frame_time'] = 0;
}
$response = $this->socialHttp()->withToken($account->access_token)
->post($this->baseUrl.'/pins', $payload);
if ($response->failed()) {
Log::error('Pinterest video pin creation failed', [
'status' => $response->status(),
'body' => $this->redactResponseBody($response->body()),
]);
$this->handleApiError($response);
}
$data = $response->json();
return [
'id' => data_get($data, 'id'),
'url' => 'https://pinterest.com/pin/'.data_get($data, 'id'),
];
return $this->createPin($account, $payload, 'Pinterest video pin creation failed');
}
private function publishCarousel(PostPlatform $postPlatform, ?string $content): array
@ -310,56 +305,19 @@ private function publishCarousel(PostPlatform $postPlatform, ?string $content):
);
}
$boardId = data_get($postPlatform->meta, 'board_id') ?? data_get($account->meta, 'default_board_id') ?? null;
if (! $boardId) {
throw new PinterestPublishException(
userMessage: 'Pinterest board_id is required',
category: ErrorCategory::ContentPolicy,
);
}
$items = $medias->map(fn ($media) => [
'url' => $media->url,
])->toArray();
$payload = [
'board_id' => $boardId,
$payload = $this->applyPinTextFields([
'board_id' => $this->resolveBoardId($postPlatform),
'media_source' => [
'source_type' => 'multiple_image_urls',
'items' => $items,
],
];
], $postPlatform, $content);
if ($content) {
$payload['description'] = $content;
}
if (! empty(data_get($postPlatform->meta, 'title'))) {
$payload['title'] = substr(data_get($postPlatform->meta, 'title'), 0, 100);
}
if (! empty(data_get($postPlatform->meta, 'link'))) {
$payload['link'] = data_get($postPlatform->meta, 'link');
}
$response = $this->socialHttp()->withToken($account->access_token)
->post($this->baseUrl.'/pins', $payload);
if ($response->failed()) {
Log::error('Pinterest carousel creation failed', [
'status' => $response->status(),
'body' => $this->redactResponseBody($response->body()),
]);
$this->handleApiError($response);
}
$data = $response->json();
return [
'id' => data_get($data, 'id'),
'url' => 'https://pinterest.com/pin/'.data_get($data, 'id'),
];
return $this->createPin($account, $payload, 'Pinterest carousel creation failed');
}
private function waitForMediaProcessing(SocialAccount $account, string $mediaId, int $maxAttempts = 30): void

View file

@ -61,6 +61,8 @@ public static function rules(): array
// Pinterest
'platforms.*.meta.board_id' => ['sometimes', 'nullable', 'string'],
'platforms.*.meta.title' => ['sometimes', 'nullable', 'string', 'max:100'],
'platforms.*.meta.link' => ['sometimes', 'nullable', 'url:http,https', 'max:2048'],
// Discord
'platforms.*.meta.channel_id' => ['sometimes', 'nullable', 'string'],
@ -77,6 +79,33 @@ public static function rules(): array
];
}
/**
* Custom validation messages for meta fields shown in the UI.
*
* @return array<string, string>
*/
public static function messages(): array
{
return [
'platforms.*.meta.link.url' => __('posts.form.pinterest.link_invalid'),
'platforms.*.meta.link.max' => __('posts.form.pinterest.link_max'),
'platforms.*.meta.title.max' => __('posts.form.pinterest.title_max'),
];
}
/**
* Friendly attribute names so default messages never expose `platforms.0.meta.*`.
*
* @return array<string, string>
*/
public static function attributes(): array
{
return [
'platforms.*.meta.title' => __('posts.form.pinterest.title'),
'platforms.*.meta.link' => __('posts.form.pinterest.link'),
];
}
/**
* Adds validation errors for per-platform meta that becomes mandatory once a
* post is published or scheduled (TikTok privacy, Pinterest board, Discord

View file

@ -158,6 +158,13 @@
'search_board' => 'البحث في اللوحات...',
'no_board_found' => 'لا توجد لوحة مطابقة لبحثك.',
'board_required' => 'اختر لوحة Pinterest لنشر هذا المنشور.',
'title' => 'العنوان',
'title_placeholder' => 'عنوان اختياري للدبوس',
'link' => 'رابط الوجهة',
'link_placeholder' => 'https://example.com',
'link_invalid' => 'أدخل رابط وجهة صالحًا (http أو https).',
'title_max' => 'يجب ألا يتجاوز العنوان 100 حرفًا.',
'link_max' => 'يجب ألا يتجاوز رابط الوجهة 2048 حرفًا.',
],
'discord' => [
'settings' => 'إعدادات Discord',

View file

@ -160,6 +160,13 @@
'search_board' => 'Pinnwände suchen...',
'no_board_found' => 'Keine Pinnwand passt zu deiner Suche.',
'board_required' => 'Wähle eine Pinterest-Pinnwand, um diesen Beitrag zu veröffentlichen.',
'title' => 'Titel',
'title_placeholder' => 'Optionaler Pin-Titel',
'link' => 'Ziel-Link',
'link_placeholder' => 'https://beispiel.com',
'link_invalid' => 'Gib einen gültigen Ziel-Link ein (http oder https).',
'title_max' => 'Der Titel darf höchstens 100 Zeichen lang sein.',
'link_max' => 'Der Ziel-Link darf höchstens 2048 Zeichen lang sein.',
],
'discord' => [
'settings' => 'Discord-Einstellungen',

View file

@ -158,6 +158,13 @@
'search_board' => 'Αναζήτηση πινάκων...',
'no_board_found' => 'Κανένας πίνακας δεν ταιριάζει με την αναζήτησή σας.',
'board_required' => 'Επιλέξτε έναν πίνακα Pinterest για να δημοσιεύσετε αυτή τη δημοσίευση.',
'title' => 'Τίτλος',
'title_placeholder' => 'Προαιρετικός τίτλος pin',
'link' => 'Σύνδεσμος προορισμού',
'link_placeholder' => 'https://example.com',
'link_invalid' => 'Εισαγάγετε έναν έγκυρο σύνδεσμο προορισμού (http ή https).',
'title_max' => 'Ο τίτλος δεν μπορεί να υπερβαίνει τους 100 χαρακτήρες.',
'link_max' => 'Ο σύνδεσμος προορισμού δεν μπορεί να υπερβαίνει τους 2048 χαρακτήρες.',
],
'discord' => [
'settings' => 'Ρυθμίσεις Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'Search boards...',
'no_board_found' => 'No board matches your search.',
'board_required' => 'Select a Pinterest board to publish this post.',
'title' => 'Title',
'title_placeholder' => 'Optional pin title',
'link' => 'Destination link',
'link_placeholder' => 'https://example.com',
'link_invalid' => 'Enter a valid destination link (http or https).',
'title_max' => 'Title may not be longer than 100 characters.',
'link_max' => 'Destination link may not be longer than 2048 characters.',
],
'discord' => [
'settings' => 'Discord Settings',

View file

@ -158,6 +158,13 @@
'search_board' => 'Buscar tableros...',
'no_board_found' => 'Ningún tablero coincide con tu búsqueda.',
'board_required' => 'Selecciona un tablero de Pinterest para publicar este post.',
'title' => 'Título',
'title_placeholder' => 'Título opcional del pin',
'link' => 'Enlace de destino',
'link_placeholder' => 'https://ejemplo.com',
'link_invalid' => 'Introduce un enlace de destino válido (http o https).',
'title_max' => 'El título no puede tener más de 100 caracteres.',
'link_max' => 'El enlace de destino no puede tener más de 2048 caracteres.',
],
'discord' => [
'settings' => 'Configuración de Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'Rechercher des tableaux...',
'no_board_found' => 'Aucun tableau ne correspond à votre recherche.',
'board_required' => 'Sélectionnez un tableau Pinterest pour publier cette publication.',
'title' => 'Titre',
'title_placeholder' => 'Titre optionnel de l’épingle',
'link' => 'Lien de destination',
'link_placeholder' => 'https://exemple.com',
'link_invalid' => 'Saisissez un lien de destination valide (http ou https).',
'title_max' => 'Le titre ne peut pas dépasser 100 caractères.',
'link_max' => 'Le lien de destination ne peut pas dépasser 2048 caractères.',
],
'discord' => [
'settings' => 'Paramètres Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'Cerca bacheche...',
'no_board_found' => 'Nessuna bacheca corrisponde alla ricerca.',
'board_required' => 'Seleziona una bacheca Pinterest per pubblicare questo post.',
'title' => 'Titolo',
'title_placeholder' => 'Titolo opzionale del pin',
'link' => 'Link di destinazione',
'link_placeholder' => 'https://esempio.com',
'link_invalid' => 'Inserisci un link di destinazione valido (http o https).',
'title_max' => 'Il titolo non può superare i 100 caratteri.',
'link_max' => 'Il link di destinazione non può superare i 2048 caratteri.',
],
'discord' => [
'settings' => 'Impostazioni Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'ボードを検索...',
'no_board_found' => '検索に一致するボードがありません。',
'board_required' => 'この投稿を公開する Pinterest ボードを選択してください。',
'title' => 'タイトル',
'title_placeholder' => '任意のピンタイトル',
'link' => 'リンク先',
'link_placeholder' => 'https://example.com',
'link_invalid' => '有効なリンク先URLを入力してください(http または https)。',
'title_max' => 'タイトルは100文字以内にしてください。',
'link_max' => 'リンク先URLは2048文字以内にしてください。',
],
'discord' => [
'settings' => 'Discord 設定',

View file

@ -158,6 +158,13 @@
'search_board' => '보드 검색...',
'no_board_found' => '검색과 일치하는 보드가 없습니다.',
'board_required' => '이 게시물을 게시할 Pinterest 보드를 선택하세요.',
'title' => '제목',
'title_placeholder' => '선택적 핀 제목',
'link' => '도착 링크',
'link_placeholder' => 'https://example.com',
'link_invalid' => '유효한 목적지 링크를 입력하세요(http 또는 https).',
'title_max' => '제목은 100자를 초과할 수 없습니다.',
'link_max' => '목적지 링크는 2048자를 초과할 수 없습니다.',
],
'discord' => [
'settings' => 'Discord 설정',

View file

@ -158,6 +158,13 @@
'search_board' => 'Borden zoeken...',
'no_board_found' => 'Geen bord komt overeen met je zoekopdracht.',
'board_required' => 'Selecteer een Pinterest-bord om deze post te publiceren.',
'title' => 'Titel',
'title_placeholder' => 'Optionele pin-titel',
'link' => 'Bestemmingslink',
'link_placeholder' => 'https://voorbeeld.com',
'link_invalid' => 'Voer een geldige bestemmingslink in (http of https).',
'title_max' => 'Titel mag niet langer zijn dan 100 tekens.',
'link_max' => 'Bestemmingslink mag niet langer zijn dan 2048 tekens.',
],
'discord' => [
'settings' => 'Discord-instellingen',

View file

@ -158,6 +158,13 @@
'search_board' => 'Szukaj tablic...',
'no_board_found' => 'Brak tablic pasujących do wyszukiwania.',
'board_required' => 'Wybierz tablicę Pinterest, aby opublikować ten post.',
'title' => 'Tytuł',
'title_placeholder' => 'Opcjonalny tytuł pina',
'link' => 'Link docelowy',
'link_placeholder' => 'https://przyklad.com',
'link_invalid' => 'Podaj prawidłowy link docelowy (http lub https).',
'title_max' => 'Tytuł nie może być dłuższy niż 100 znaków.',
'link_max' => 'Link docelowy nie może być dłuższy niż 2048 znaków.',
],
'discord' => [
'settings' => 'Ustawienia Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'Pesquisar quadros...',
'no_board_found' => 'Nenhum quadro encontrado.',
'board_required' => 'Selecione um quadro do Pinterest para publicar este post.',
'title' => 'Título',
'title_placeholder' => 'Título opcional do pin',
'link' => 'Link de destino',
'link_placeholder' => 'https://exemplo.com',
'link_invalid' => 'Informe um link de destino válido (http ou https).',
'title_max' => 'O título pode ter no máximo 100 caracteres.',
'link_max' => 'O link de destino pode ter no máximo 2048 caracteres.',
],
'discord' => [
'settings' => 'Configurações do Discord',

View file

@ -158,6 +158,13 @@
'search_board' => 'Поиск досок...',
'no_board_found' => 'Нет досок по вашему запросу.',
'board_required' => 'Выберите доску Pinterest, чтобы опубликовать этот пост.',
'title' => 'Заголовок',
'title_placeholder' => 'Необязательный заголовок пина',
'link' => 'Ссылка назначения',
'link_placeholder' => 'https://example.com',
'link_invalid' => 'Укажите корректную ссылку назначения (http или https).',
'title_max' => 'Заголовок не может быть длиннее 100 символов.',
'link_max' => 'Ссылка назначения не может быть длиннее 2048 символов.',
],
'discord' => [
'settings' => 'Настройки Discord',

View file

@ -160,6 +160,13 @@
'search_board' => 'Pano ara...',
'no_board_found' => 'Aramanızla eşleşen pano yok.',
'board_required' => 'Bu gönderiyi yayınlamak için bir Pinterest panosu seçin.',
'title' => 'Başlık',
'title_placeholder' => 'İsteğe bağlı pin başlığı',
'link' => 'Hedef bağlantı',
'link_placeholder' => 'https://ornek.com',
'link_invalid' => 'Geçerli bir hedef bağlantısı girin (http veya https).',
'title_max' => 'Başlık en fazla 100 karakter olabilir.',
'link_max' => 'Hedef bağlantısı en fazla 2048 karakter olabilir.',
],
'discord' => [
'settings' => 'Discord Ayarları',

View file

@ -158,6 +158,13 @@
'search_board' => '搜索图板…',
'no_board_found' => '没有与搜索匹配的图板。',
'board_required' => '请选择一个 Pinterest 图板以发布此帖子。',
'title' => '标题',
'title_placeholder' => '可选的 Pin 标题',
'link' => '目标链接',
'link_placeholder' => 'https://example.com',
'link_invalid' => '请输入有效的目标链接(http 或 https)。',
'title_max' => '标题不能超过 100 个字符。',
'link_max' => '目标链接不能超过 2048 个字符。',
],
'discord' => [
'settings' => 'Discord 设置',

View file

@ -14,6 +14,7 @@ import {
ComboboxList,
ComboboxTrigger,
} from '@/components/ui/combobox';
import { Input } from '@/components/ui/input';
import { getMediaValidationWarning } from '@/composables/useMedia';
import { usePageErrors } from '@/composables/usePageErrors';
import { getPlatformLogo } from '@/composables/usePlatformLogo';
@ -95,15 +96,39 @@ const selectedBoard = computed<BoardOption | undefined>({
set: (board) => emit('update:meta', { ...props.meta, board_id: board?.value ?? null }),
});
// Surface the backend validation error keyed by platform index
// (`platforms.0.meta.board_id`). Suffix match avoids threading the index
// through props. Cleared as soon as a board is picked locally so the user
// doesn't see a stale error after fixing the issue.
const pinTitle = computed({
get: () => (props.meta?.title as string | undefined) || '',
set: (value: string) => {
// Whitespace-only clears the field; keep interior spaces while typing.
emit('update:meta', { ...props.meta, title: value.trim() === '' ? null : value });
},
});
const pinLink = computed({
get: () => (props.meta?.link as string | undefined) || '',
set: (value: string) => {
// Whitespace-only clears the field; keep partial URLs while typing.
emit('update:meta', { ...props.meta, link: value.trim() === '' ? null : value });
},
});
// Surface backend validation errors keyed by platform index
// (`platforms.0.meta.*`). Suffix match avoids threading the index through props.
// Board clears as soon as one is picked so the user doesn't see a stale error.
const errors = usePageErrors();
const boardError = computed<string | undefined>(() => {
if (props.meta?.board_id) return undefined;
if (props.meta?.board_id) {
return undefined;
}
return Object.entries(errors.value).find(([key]) => key.endsWith('.meta.board_id'))?.[1];
});
const titleError = computed<string | undefined>(() => {
return Object.entries(errors.value).find(([key]) => key.endsWith('.meta.title'))?.[1];
});
const linkError = computed<string | undefined>(() => {
return Object.entries(errors.value).find(([key]) => key.endsWith('.meta.link'))?.[1];
});
</script>
<template>
@ -214,6 +239,30 @@ const boardError = computed<string | undefined>(() => {
</template>
</div>
<div class="space-y-2">
<p class="text-[11px] font-black uppercase tracking-widest text-foreground/60">{{ $t('posts.form.pinterest.title') }}</p>
<Input
v-model="pinTitle"
type="text"
:placeholder="$t('posts.form.pinterest.title_placeholder')"
:disabled="disabled || previewOnly"
:class="titleError ? 'border-rose-500' : undefined"
/>
<InputError :message="titleError" />
</div>
<div class="space-y-2">
<p class="text-[11px] font-black uppercase tracking-widest text-foreground/60">{{ $t('posts.form.pinterest.link') }}</p>
<Input
v-model="pinLink"
type="text"
:placeholder="$t('posts.form.pinterest.link_placeholder')"
:disabled="disabled || previewOnly"
:class="linkError ? 'border-rose-500' : undefined"
/>
<InputError :message="linkError" />
</div>
<p
v-if="warning && !previewOnly"
class="flex items-start gap-2 rounded-lg border-2 border-foreground bg-rose-50 p-2 text-xs font-semibold text-rose-700"

View file

@ -19,11 +19,15 @@ interface Props {
content: string;
media: MediaItem[];
contentType?: string;
meta?: Record<string, any>;
}
const props = defineProps<Props>();
const isCarousel = computed(() => props.contentType === 'pinterest_carousel');
const pinTitle = computed(() => (props.meta?.title as string | undefined) || '');
const pinLink = computed(() => (props.meta?.link as string | undefined) || '');
</script>
<template>
@ -116,10 +120,25 @@ const isCarousel = computed(() => props.contentType === 'pinterest_carousel');
<!-- Pin Info -->
<div class="p-2.5">
<!-- Description -->
<div v-if="content" class="text-[13px] text-[#111111] dark:text-[#e0e0e0] line-clamp-2 leading-[17px]">
<div v-if="pinTitle" class="text-[14px] font-semibold text-[#111111] dark:text-[#e0e0e0] line-clamp-2 leading-[18px]">
{{ pinTitle }}
</div>
<div
v-if="content"
class="text-[13px] text-[#111111] dark:text-[#e0e0e0] line-clamp-2 leading-[17px]"
:class="pinTitle ? 'mt-1' : ''"
>
{{ content }}
</div>
<a
v-if="pinLink"
:href="pinLink"
class="mt-1 block truncate text-[11px] text-[#767676] dark:text-[#a0a0a0]"
target="_blank"
rel="noopener noreferrer"
>
{{ pinLink }}
</a>
<!-- User Info -->
<div class="flex items-center gap-2 mt-2">

View file

@ -288,3 +288,104 @@
expect($platform->fresh()->meta['channel_id'])->toBe('444555666');
Queue::assertPushed(PublishPost::class);
});
it('persists Pinterest title and link meta on store', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$this->withHeaders($this->headers)
->postJson(route('api.posts.store'), [
'content' => 'Shared caption',
'platforms' => [[
'social_account_id' => $pinterest->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'title' => 'Pin Title',
'link' => 'https://example.com/product',
],
]],
])
->assertCreated();
$meta = PostPlatform::where('social_account_id', $pinterest->id)->sole()->meta;
expect(data_get($meta, 'board_id'))->toBe('board-1')
->and(data_get($meta, 'title'))->toBe('Pin Title')
->and(data_get($meta, 'link'))->toBe('https://example.com/product')
->and(array_key_exists('description', $meta))->toBeFalse();
});
it('updates Pinterest title and link meta', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$post = Post::factory()->create([
'workspace_id' => $this->workspace->id,
'user_id' => $this->user->id,
'content' => 'Shared caption',
]);
$platform = PostPlatform::factory()->pinterest()->create([
'post_id' => $post->id,
'social_account_id' => $pinterest->id,
'enabled' => true,
'meta' => ['board_id' => 'board-1'],
]);
$this->withHeaders($this->headers)
->putJson(route('api.posts.update', $post), [
'status' => PostStatus::Draft->value,
'platforms' => [[
'id' => $platform->id,
'meta' => [
'board_id' => 'board-1',
'title' => 'Updated Title',
'link' => 'https://example.com/updated',
],
]],
])
->assertOk();
$meta = $platform->fresh()->meta;
expect(data_get($meta, 'title'))->toBe('Updated Title')
->and(data_get($meta, 'link'))->toBe('https://example.com/updated')
->and(data_get($meta, 'board_id'))->toBe('board-1');
});
it('rejects invalid Pinterest title and link on store', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$this->withHeaders($this->headers)
->postJson(route('api.posts.store'), [
'content' => 'Hello',
'platforms' => [[
'social_account_id' => $pinterest->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'title' => str_repeat('t', 101),
'link' => 'not-a-url',
],
]],
])
->assertUnprocessable()
->assertJsonValidationErrors([
'platforms.0.meta.title' => __('posts.form.pinterest.title_max'),
'platforms.0.meta.link' => __('posts.form.pinterest.link_invalid'),
]);
});
it('rejects non-http Pinterest links', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$this->withHeaders($this->headers)
->postJson(route('api.posts.store'), [
'content' => 'Hello',
'platforms' => [[
'social_account_id' => $pinterest->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => ['link' => 'ftp://files.example.com/pin'],
]],
])
->assertUnprocessable()
->assertJsonValidationErrors([
'platforms.0.meta.link' => __('posts.form.pinterest.link_invalid'),
]);
});

View file

@ -287,3 +287,85 @@
$response->assertOk();
Queue::assertPushed(PublishPost::class);
});
test('create post persists Pinterest title and link meta', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$response = TryPostServer::actingAs($this->user)
->tool(CreatePostTool::class, [
'content' => 'Shared caption',
'platforms' => [[
'social_account_id' => $pinterest->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'title' => 'Pin Title',
'link' => 'https://example.com/product',
],
]],
]);
$response->assertOk();
$meta = PostPlatform::where('social_account_id', $pinterest->id)->sole()->meta;
expect(data_get($meta, 'title'))->toBe('Pin Title')
->and(data_get($meta, 'link'))->toBe('https://example.com/product')
->and(array_key_exists('description', $meta))->toBeFalse();
});
test('update post merges Pinterest title and link meta', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$post = Post::factory()->create([
'workspace_id' => $this->workspace->id,
'user_id' => $this->user->id,
'status' => PostStatus::Draft,
'content' => 'Shared caption',
]);
$platform = PostPlatform::factory()->pinterest()->create([
'post_id' => $post->id,
'social_account_id' => $pinterest->id,
'enabled' => true,
'meta' => ['board_id' => 'board-1'],
]);
$response = TryPostServer::actingAs($this->user)
->tool(UpdatePostTool::class, [
'post_id' => $post->id,
'platforms' => [[
'id' => $platform->id,
'meta' => [
'board_id' => 'board-1',
'title' => 'Updated Title',
'link' => 'https://example.com/updated',
],
]],
]);
$response->assertOk();
$meta = $platform->fresh()->meta;
expect(data_get($meta, 'title'))->toBe('Updated Title')
->and(data_get($meta, 'link'))->toBe('https://example.com/updated')
->and(data_get($meta, 'board_id'))->toBe('board-1');
});
test('create post rejects invalid Pinterest destination link', function () {
$pinterest = SocialAccount::factory()->create(['workspace_id' => $this->workspace->id, 'platform' => Platform::Pinterest]);
$response = TryPostServer::actingAs($this->user)
->tool(CreatePostTool::class, [
'content' => 'Shared caption',
'platforms' => [[
'social_account_id' => $pinterest->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'link' => 'ftp://files.example.com/pin',
],
]],
]);
$response->assertHasErrors();
});

View file

@ -378,6 +378,7 @@
]);
$this->post->update([
'content' => 'Check out this pin!',
'media' => [
[
'id' => 'test-media-id',
@ -396,12 +397,150 @@
'*' => Http::response('fake-image-content', 200),
]);
$this->publisher->publish($this->postPlatform);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
return str_contains($request->url(), '/v5/pins')
&& $request['title'] === 'My Pin Title'
&& $request['link'] === 'https://example.com/my-page';
&& $request['link'] === 'https://example.com/my-page'
&& $request['description'] === 'Check out this pin!';
});
});
test('pinterest publisher uses post content as description and ignores meta description', function () {
$this->post->update([
'content' => 'Shared post caption',
'media' => [
[
'id' => 'test-media-id',
'path' => 'media/2026-01/image.jpg',
'url' => 'https://example.com/media/2026-01/image.jpg',
'mime_type' => 'image/jpeg',
'original_filename' => 'image.jpg',
],
],
]);
$this->postPlatform->update([
'meta' => [
'board_id' => 'board_123',
'description' => 'Stale meta description must be ignored',
],
]);
Http::fake([
'*/v5/pins' => Http::response(['id' => 'pin_123456'], 200),
'*' => Http::response('fake-image-content', 200),
]);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
return str_contains($request->url(), '/v5/pins')
&& $request['description'] === 'Shared post caption';
});
});
test('pinterest publisher omits description when post content is blank', function () {
$this->post->update([
'content' => '',
'media' => [
[
'id' => 'test-media-id',
'path' => 'media/2026-01/image.jpg',
'url' => 'https://example.com/media/2026-01/image.jpg',
'mime_type' => 'image/jpeg',
'original_filename' => 'image.jpg',
],
],
]);
Http::fake([
'*/v5/pins' => Http::response(['id' => 'pin_123456'], 200),
'*' => Http::response('fake-image-content', 200),
]);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
return str_contains($request->url(), '/v5/pins')
&& ! array_key_exists('description', $request->data());
});
});
test('pinterest publisher truncates title to 100 characters', function () {
$longTitle = str_repeat('T', 150);
$this->postPlatform->update([
'meta' => [
'board_id' => 'board_123',
'title' => $longTitle,
],
]);
$this->post->update([
'content' => 'Within limit',
'media' => [
[
'id' => 'test-media-id',
'path' => 'media/2026-01/image.jpg',
'url' => 'https://example.com/media/2026-01/image.jpg',
'mime_type' => 'image/jpeg',
'original_filename' => 'image.jpg',
],
],
]);
Http::fake([
'*/v5/pins' => Http::response(['id' => 'pin_truncated'], 200),
'*' => Http::response('fake-image-content', 200),
]);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
return str_contains($request->url(), '/v5/pins')
&& mb_strlen($request['title']) === 100
&& $request['description'] === 'Within limit';
});
});
test('pinterest publisher omits blank title and link', function () {
$this->postPlatform->update([
'meta' => [
'board_id' => 'board_123',
'title' => '',
'link' => '',
],
]);
$this->post->update([
'content' => 'Caption only',
'media' => [
[
'id' => 'test-media-id',
'path' => 'media/2026-01/image.jpg',
'url' => 'https://example.com/media/2026-01/image.jpg',
'mime_type' => 'image/jpeg',
'original_filename' => 'image.jpg',
],
],
]);
Http::fake([
'*/v5/pins' => Http::response(['id' => 'pin_no_title_link'], 200),
'*' => Http::response('fake-image-content', 200),
]);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
$data = $request->data();
return str_contains($request->url(), '/v5/pins')
&& $data['description'] === 'Caption only'
&& ! array_key_exists('title', $data)
&& ! array_key_exists('link', $data);
});
});
@ -642,6 +781,107 @@
&& data_get($request->data(), 'media_source.cover_image_key_frame_time') === 0);
});
test('pinterest publisher includes title description and link on video pins', function () {
$this->postPlatform->update([
'content_type' => ContentType::PinterestVideoPin,
'meta' => [
'board_id' => 'board_123',
'title' => 'Video Title',
'link' => 'https://example.com/video',
],
]);
$this->post->update([
'content' => 'Video pin caption',
'media' => [
[
'id' => 'test-media-video',
'path' => 'media/2026-01/video.mp4',
'url' => 'https://example.com/media/2026-01/video.mp4',
'mime_type' => 'video/mp4',
'original_filename' => 'video.mp4',
],
],
]);
$s3UploadUrl = 'https://pinterest-media-upload.s3.amazonaws.com/upload';
Http::fake(function ($request) use ($s3UploadUrl) {
$url = $request->url();
if (str_contains($url, '/v5/media') && $request->method() === 'POST') {
return Http::response([
'media_id' => 'media_video_789',
'upload_url' => $s3UploadUrl,
'upload_parameters' => ['key' => 'uploads/video.mp4'],
], 201);
}
if ($url === $s3UploadUrl) {
return Http::response('', 204);
}
if (str_contains($url, '/v5/media/media_video_789')) {
return Http::response(['status' => 'succeeded'], 200);
}
if (str_contains($url, '/v5/pins')) {
return Http::response(['id' => 'video_pin_999'], 200);
}
return Http::response('fake-video-content', 200);
});
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(fn ($request) => $request->url() === config('trypost.platforms.pinterest.api').'/pins'
&& data_get($request->data(), 'title') === 'Video Title'
&& data_get($request->data(), 'description') === 'Video pin caption'
&& data_get($request->data(), 'link') === 'https://example.com/video'
&& data_get($request->data(), 'media_source.source_type') === 'video_id');
});
test('pinterest publisher includes title description and link on carousels', function () {
$mediaItems = [];
for ($i = 1; $i <= 2; $i++) {
$mediaItems[] = [
'id' => "test-media-{$i}",
'path' => "media/2026-01/image{$i}.jpg",
'url' => "https://example.com/media/2026-01/image{$i}.jpg",
'mime_type' => 'image/jpeg',
'original_filename' => "image{$i}.jpg",
];
}
$this->postPlatform->update([
'content_type' => ContentType::PinterestCarousel,
'meta' => [
'board_id' => 'board_123',
'title' => 'Carousel Title',
'link' => 'https://example.com/carousel',
],
]);
$this->post->update([
'content' => 'Carousel pin caption',
'media' => $mediaItems,
]);
Http::fake([
'*/v5/pins' => Http::response(['id' => 'carousel_pin_123'], 200),
]);
$this->publisher->publish($this->postPlatform->fresh());
Http::assertSent(function ($request) {
return str_contains($request->url(), '/v5/pins')
&& $request['title'] === 'Carousel Title'
&& $request['description'] === 'Carousel pin caption'
&& $request['link'] === 'https://example.com/carousel'
&& $request['media_source']['source_type'] === 'multiple_image_urls';
});
});
test('pinterest video pin uses the provided cover image url over the default frame', function () {
$this->postPlatform->update([
'content_type' => ContentType::PinterestVideoPin,

View file

@ -585,3 +585,145 @@
])
->assertSessionDoesntHaveErrors('platforms.0.meta.channel_id');
});
test('saving a pinterest draft persists title and link meta', function () {
$pinterestAccount = SocialAccount::factory()->create([
'workspace_id' => $this->workspace->id,
'platform' => Platform::Pinterest,
]);
$pinterestPlatform = PostPlatform::factory()->pinterest()->create([
'post_id' => $this->post->id,
'social_account_id' => $pinterestAccount->id,
'meta' => ['board_id' => 'board-1'],
]);
$this->actingAs($this->user)
->put(route('app.posts.update', $this->post), [
'status' => Status::Draft->value,
'content' => 'Shared caption',
'platforms' => [[
'id' => $pinterestPlatform->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'title' => 'Pin Title',
'link' => 'https://example.com/product',
],
]],
])
->assertSessionDoesntHaveErrors();
$meta = $pinterestPlatform->fresh()->meta;
expect(data_get($meta, 'title'))->toBe('Pin Title')
->and(data_get($meta, 'link'))->toBe('https://example.com/product')
->and(array_key_exists('description', $meta))->toBeFalse();
});
test('clearing pinterest title and link removes the meta keys', function () {
$pinterestAccount = SocialAccount::factory()->create([
'workspace_id' => $this->workspace->id,
'platform' => Platform::Pinterest,
]);
$pinterestPlatform = PostPlatform::factory()->pinterest()->create([
'post_id' => $this->post->id,
'social_account_id' => $pinterestAccount->id,
'meta' => [
'board_id' => 'board-1',
'title' => 'Keep me gone',
'link' => 'https://example.com/gone',
],
]);
$this->actingAs($this->user)
->put(route('app.posts.update', $this->post), [
'status' => Status::Draft->value,
'platforms' => [[
'id' => $pinterestPlatform->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'title' => null,
'link' => null,
],
]],
])
->assertSessionDoesntHaveErrors();
$meta = $pinterestPlatform->fresh()->meta;
expect(data_get($meta, 'board_id'))->toBe('board-1')
->and(array_key_exists('title', $meta))->toBeFalse()
->and(array_key_exists('link', $meta))->toBeFalse();
});
test('pinterest rejects invalid link when scheduling', function () {
$pinterestAccount = SocialAccount::factory()->create([
'workspace_id' => $this->workspace->id,
'platform' => Platform::Pinterest,
]);
$pinterestPlatform = PostPlatform::factory()->pinterest()->create([
'post_id' => $this->post->id,
'social_account_id' => $pinterestAccount->id,
'meta' => ['board_id' => 'board-1'],
]);
$mediaPayload = [
[
'id' => 'test-image',
'path' => 'media/2026-01/pin.jpg',
'url' => 'https://example.com/media/2026-01/pin.jpg',
'type' => 'image',
'mime_type' => 'image/jpeg',
'original_filename' => 'pin.jpg',
],
];
$this->actingAs($this->user)
->put(route('app.posts.update', $this->post), [
'status' => Status::Scheduled->value,
'scheduled_at' => now()->addHour()->toIso8601String(),
'content' => 'Ready to schedule',
'media' => $mediaPayload,
'platforms' => [[
'id' => $pinterestPlatform->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'board_id' => 'board-1',
'link' => 'not-a-url',
],
]],
])
->assertSessionHasErrors([
'platforms.0.meta.link' => __('posts.form.pinterest.link_invalid'),
]);
});
test('pinterest meta title and link validation bounds are enforced', function () {
$pinterestAccount = SocialAccount::factory()->create([
'workspace_id' => $this->workspace->id,
'platform' => Platform::Pinterest,
]);
$pinterestPlatform = PostPlatform::factory()->pinterest()->create([
'post_id' => $this->post->id,
'social_account_id' => $pinterestAccount->id,
'meta' => [],
]);
$this->actingAs($this->user)
->put(route('app.posts.update', $this->post), [
'status' => Status::Draft->value,
'platforms' => [[
'id' => $pinterestPlatform->id,
'content_type' => ContentType::PinterestPin->value,
'meta' => [
'title' => str_repeat('t', 101),
'link' => 'not-a-url',
],
]],
])
->assertSessionHasErrors([
'platforms.0.meta.title' => __('posts.form.pinterest.title_max'),
'platforms.0.meta.link' => __('posts.form.pinterest.link_invalid'),
]);
});

View file

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
use App\Support\PostPlatformMetaRules;
test('custom meta messages only cover pinterest title and link', function () {
expect(PostPlatformMetaRules::messages())->toBe([
'platforms.*.meta.link.url' => __('posts.form.pinterest.link_invalid'),
'platforms.*.meta.link.max' => __('posts.form.pinterest.link_max'),
'platforms.*.meta.title.max' => __('posts.form.pinterest.title_max'),
]);
});
test('custom meta attributes only rename pinterest title and link', function () {
expect(PostPlatformMetaRules::attributes())->toBe([
'platforms.*.meta.title' => __('posts.form.pinterest.title'),
'platforms.*.meta.link' => __('posts.form.pinterest.link'),
]);
});
test('shared meta rules still include non-pinterest platform fields', function () {
$rules = PostPlatformMetaRules::rules();
expect($rules)->toHaveKeys([
'platforms.*.meta.aspect_ratio',
'platforms.*.meta.privacy_level',
'platforms.*.meta.board_id',
'platforms.*.meta.channel_id',
'platforms.*.meta.title',
'platforms.*.meta.link',
]);
});