Full per-platform meta parity for posts (API + MCP) - #101
Merged
Conversation
Centralize per-platform PostPlatform.meta validation in PostPlatformMetaRules (shared by web, REST API and MCP). The API and MCP previously only accepted aspect_ratio, silently stripping channel_id/board_id/privacy_level and the rest via validated(), so Discord/Pinterest/TikTok couldn't be configured or published through those entry points. Now all per-platform meta is accepted and persisted, required-on-publish is enforced on API update (TikTok privacy, Pinterest board, Discord channel), and the MCP publish tool guards a post's stored meta before dispatching. Adds API + MCP tests and a PostPlatform discord() factory state.
Broaden the post meta tests beyond Discord: store persists Instagram aspect ratio, Pinterest board, TikTok privacy + flags; API update enforces TikTok privacy and Pinterest board on publish and allows drafts without required meta; MCP update merges meta and the publish guard ignores disabled platforms.
…etaRules The shared rules() returned only meta sub-keys, so every caller still repeated its own 'platforms.*.meta' => array parent (with slightly different sometimes/ nullable combos). Fold the parent into rules() with a single safe contract so callers just spread one source for the whole meta block.
Record in CLAUDE.md that all platforms.*.meta validation and required-on-publish logic lives only in PostPlatformMetaRules, why (validated() strips unlisted keys), and where to add new per-platform meta + tests.
- Assert nested Discord meta keys (mention token/label, embed title/color) survive validated(), replacing a vacuous coalesced assertion. - Cover the MCP publish guard for TikTok privacy and Pinterest board, not just Discord. - Use assertUnprocessable() to match sibling API tests; type-hint the API UpdatePostRequest withValidator closure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The public REST API and MCP tools only validated
aspect_ratioinPostPlatform.meta. Becausevalidated()strips keys without rules, every other per-platform setting (channel_id,board_id,privacy_level,mentions,embeds, TikTok flags) was silently dropped. As a result Discord, Pinterest and TikTok could not be configured or published via API/MCP — only via the web UI.What
app/Support/PostPlatformMetaRules.php— single source of truth for per-platform meta:rules()— allmeta.*validation rules.addRequiredOnPublishErrors()— required-on-publish from submitted request platforms (web + API update).assertStoredPostPublishable()— required-on-publish from a post's stored state (MCP publish, which doesn't resubmit platforms).requiredMetaViolation()— one definition of what each platform requires to publish.UpdatePostRequestrefactored to use the shared source (DRY, no behavior change).StorePostRequest/UpdatePostRequestnow accept all per-platform meta; update enforces required-on-publish (TikTok privacy, Pinterest board, Discord channel).CreatePostTool/UpdatePostToolaccept all per-platform meta, with documented schemas.PublishPostToolguards a post's stored meta before dispatching, so a misconfigured post fails fast with a clear message instead of only at publish time.Tests
tests/Feature/Api/PostApiPlatformMetaTest.php— API persists Discord/Pinterest/TikTok meta, rejects publishing Discord without a channel, publishes with a channel.tests/Feature/Mcp/PostPlatformMetaToolTest.php— MCP create persists meta, publish guards/permits based on the channel.PostPlatform::factory()->discord()state added.Full suite green (2092 passed).