diff --git a/app/Actions/Post/CreatePost.php b/app/Actions/Post/CreatePost.php index 2cda0693..a0f439e8 100644 --- a/app/Actions/Post/CreatePost.php +++ b/app/Actions/Post/CreatePost.php @@ -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, + ); } } diff --git a/app/Actions/Post/UpdatePost.php b/app/Actions/Post/UpdatePost.php index 45a694ab..7bb2fac1 100644 --- a/app/Actions/Post/UpdatePost.php +++ b/app/Actions/Post/UpdatePost.php @@ -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, + ); } } diff --git a/app/Http/Requests/Api/Post/StorePostRequest.php b/app/Http/Requests/Api/Post/StorePostRequest.php index 00b98f24..8f19cb3b 100644 --- a/app/Http/Requests/Api/Post/StorePostRequest.php +++ b/app/Http/Requests/Api/Post/StorePostRequest.php @@ -61,6 +61,22 @@ public function rules(): array ]; } + /** + * @return array + */ + public function messages(): array + { + return PostPlatformMetaRules::messages(); + } + + /** + * @return array + */ + public function attributes(): array + { + return PostPlatformMetaRules::attributes(); + } + /** * @return Collection */ diff --git a/app/Http/Requests/Api/Post/UpdatePostRequest.php b/app/Http/Requests/Api/Post/UpdatePostRequest.php index 79bfa5f5..2796b80f 100644 --- a/app/Http/Requests/Api/Post/UpdatePostRequest.php +++ b/app/Http/Requests/Api/Post/UpdatePostRequest.php @@ -64,6 +64,22 @@ public function rules(): array ]; } + /** + * @return array + */ + public function messages(): array + { + return PostPlatformMetaRules::messages(); + } + + /** + * @return array + */ + public function attributes(): array + { + return PostPlatformMetaRules::attributes(); + } + public function withValidator(Validator $validator): void { $validator->after(function (Validator $validator): void { diff --git a/app/Http/Requests/App/Post/UpdatePostRequest.php b/app/Http/Requests/App/Post/UpdatePostRequest.php index 6aed0fab..83647284 100644 --- a/app/Http/Requests/App/Post/UpdatePostRequest.php +++ b/app/Http/Requests/App/Post/UpdatePostRequest.php @@ -61,6 +61,22 @@ public function rules(): array ]; } + /** + * @return array + */ + public function messages(): array + { + return PostPlatformMetaRules::messages(); + } + + /** + * @return array + */ + public function attributes(): array + { + return PostPlatformMetaRules::attributes(); + } + public function withValidator(Validator $validator): void { $validator->after(function (Validator $validator): void { diff --git a/app/Mcp/Tools/Post/CreatePostTool.php b/app/Mcp/Tools/Post/CreatePostTool.php index 95258218..933f1380 100644 --- a/app/Mcp/Tools/Post/CreatePostTool.php +++ b/app/Mcp/Tools/Post/CreatePostTool.php @@ -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.'), ]; diff --git a/app/Mcp/Tools/Post/UpdatePostTool.php b/app/Mcp/Tools/Post/UpdatePostTool.php index 9e1d5d43..19eb5b00 100644 --- a/app/Mcp/Tools/Post/UpdatePostTool.php +++ b/app/Mcp/Tools/Post/UpdatePostTool.php @@ -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.'), ]; diff --git a/app/Services/Social/PinterestPublisher.php b/app/Services/Social/PinterestPublisher.php index 87dfb1d5..ecdbaabc 100644 --- a/app/Services/Social/PinterestPublisher.php +++ b/app/Services/Social/PinterestPublisher.php @@ -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 $payload + * @return array + */ + 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 $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 diff --git a/app/Support/PostPlatformMetaRules.php b/app/Support/PostPlatformMetaRules.php index 00f6d7b2..cfb57b80 100644 --- a/app/Support/PostPlatformMetaRules.php +++ b/app/Support/PostPlatformMetaRules.php @@ -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 + */ + 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 + */ + 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 diff --git a/lang/ar/posts.php b/lang/ar/posts.php index 3f3b800f..5bc649b3 100644 --- a/lang/ar/posts.php +++ b/lang/ar/posts.php @@ -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', diff --git a/lang/de/posts.php b/lang/de/posts.php index de87cbed..4445d139 100644 --- a/lang/de/posts.php +++ b/lang/de/posts.php @@ -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', diff --git a/lang/el/posts.php b/lang/el/posts.php index 03e36c60..1f2edd34 100644 --- a/lang/el/posts.php +++ b/lang/el/posts.php @@ -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', diff --git a/lang/en/posts.php b/lang/en/posts.php index 8878a707..918c0c29 100644 --- a/lang/en/posts.php +++ b/lang/en/posts.php @@ -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', diff --git a/lang/es/posts.php b/lang/es/posts.php index 9e00e325..a2d8110b 100644 --- a/lang/es/posts.php +++ b/lang/es/posts.php @@ -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', diff --git a/lang/fr/posts.php b/lang/fr/posts.php index 79630288..6e7ffc3b 100644 --- a/lang/fr/posts.php +++ b/lang/fr/posts.php @@ -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', diff --git a/lang/it/posts.php b/lang/it/posts.php index 3f0d43e0..4d08795f 100644 --- a/lang/it/posts.php +++ b/lang/it/posts.php @@ -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', diff --git a/lang/ja/posts.php b/lang/ja/posts.php index 53cc227a..1af1a443 100644 --- a/lang/ja/posts.php +++ b/lang/ja/posts.php @@ -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 設定', diff --git a/lang/ko/posts.php b/lang/ko/posts.php index 8bb2ae08..bd8c1ab9 100644 --- a/lang/ko/posts.php +++ b/lang/ko/posts.php @@ -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 설정', diff --git a/lang/nl/posts.php b/lang/nl/posts.php index eaa2335d..9a83be40 100644 --- a/lang/nl/posts.php +++ b/lang/nl/posts.php @@ -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', diff --git a/lang/pl/posts.php b/lang/pl/posts.php index 74271f4a..c040718f 100644 --- a/lang/pl/posts.php +++ b/lang/pl/posts.php @@ -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', diff --git a/lang/pt-BR/posts.php b/lang/pt-BR/posts.php index 8d40e961..10ccc0fe 100644 --- a/lang/pt-BR/posts.php +++ b/lang/pt-BR/posts.php @@ -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', diff --git a/lang/ru/posts.php b/lang/ru/posts.php index a2efc84e..3c83c63e 100644 --- a/lang/ru/posts.php +++ b/lang/ru/posts.php @@ -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', diff --git a/lang/tr/posts.php b/lang/tr/posts.php index a7024788..22e9f3e9 100644 --- a/lang/tr/posts.php +++ b/lang/tr/posts.php @@ -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ı', diff --git a/lang/zh/posts.php b/lang/zh/posts.php index 9cf3a6a7..4f281001 100644 --- a/lang/zh/posts.php +++ b/lang/zh/posts.php @@ -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 设置', diff --git a/resources/js/components/posts/editor/PinterestSettings.vue b/resources/js/components/posts/editor/PinterestSettings.vue index e3c6c78a..dfd8d8ce 100644 --- a/resources/js/components/posts/editor/PinterestSettings.vue +++ b/resources/js/components/posts/editor/PinterestSettings.vue @@ -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({ 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(() => { - 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(() => { + return Object.entries(errors.value).find(([key]) => key.endsWith('.meta.title'))?.[1]; +}); +const linkError = computed(() => { + return Object.entries(errors.value).find(([key]) => key.endsWith('.meta.link'))?.[1]; +}); +
+

{{ $t('posts.form.pinterest.title') }}

+ + +
+ +
+

{{ $t('posts.form.pinterest.link') }}

+ + +
+

; } const props = defineProps(); 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) || '');