feat: Add Ghost CMS integration#1324
Conversation
|
Someone is attempting to deploy a commit to the Listinai Team on Vercel. A member of the Team first needs to authorize it. |
0a826c8 to
5f1db3a
Compare
5f1db3a to
4ddf91d
Compare
| try { | ||
| const updatedPost = await api.posts.edit(updateData, { | ||
| source: 'html', | ||
| include: 'tags,authors' | ||
| }); |
There was a problem hiding this comment.
Bug: The update() and changeStatus() methods are missing the required updated_at field in Ghost API calls, which will cause all post updates to fail.
Severity: CRITICAL
Suggested Fix
Before calling api.posts.edit() in both the update() and changeStatus() methods, first fetch the current post using api.posts.read({ id: ghostPostId }). Then, include the updated_at value from the fetched post in the updateData object sent to the API.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: libraries/nestjs-libraries/src/integrations/social/ghost.provider.ts#L973-L977
Potential issue: The `update()` and `changeStatus()` methods in the Ghost provider fail
to include the `updated_at` field in the payload for `api.posts.edit()` calls. The Ghost
Admin API requires this field for optimistic concurrency control to prevent write
conflicts. Its absence will cause the API to return a 409 `UPDATE_COLLISION` error for
every update attempt, effectively breaking all post editing and status change
functionality.
Ghost Admin API requires updated_at timestamp for post edits to prevent UPDATE_COLLISION (409) errors. The fix fetches current post state before editing to obtain the correct updated_at value. - update() method: fetch current post, include updated_at in edit - changeStatus() method: fetch current post, include updated_at in edit
siva-sub
left a comment
There was a problem hiding this comment.
✅ Fixes Applied
1. updated_at for Optimistic Concurrency (CRITICAL)
Fixed in commit ff75abe.
The update() and changeStatus() methods now fetch the current post using api.posts.read({ id: ghostPostId }) before calling api.posts.edit(), and include the updated_at timestamp from the fetched post.
// update() method - lines 974-981
const currentPost = await api.posts.read({ id: ghostPostId }, { include: 'tags,authors' });
if (!currentPost) {
throw new Error('Post not found');
}
updateData.updated_at = currentPost.updated_at;This satisfies Ghost Admin API's optimistic concurrency control requirement and prevents 409 UPDATE_COLLISION errors.
2. email_only validator (HIGH)
This appears to already be correct in the codebase - ghost.dto.ts line 129 shows @IsBoolean() decorator on the email_only?: boolean field. The Sentry bot comment may have been based on an outdated code snapshot.
- Add ghost:status - Get status of a Ghost post (draft/published/scheduled) - Add ghost:publish - Publish a Ghost draft immediately - Add ghost:unpublish - Convert published post back to draft - Add ghost:schedule - Schedule a Ghost post for future publication - Add ghost:delete - Delete a Ghost post - Add posts:reschedule - Reschedule any post to a new date API methods added: - updatePostDate() - Update post schedule - getPostStatus() - Get provider post status - changePostStatus() - Change post status (draft/published/scheduled) - deleteProviderPost() - Delete post from provider Ref: gitroomhq/postiz-app#1324
- Add member_status parameter for preview (public/members/paid) - Add include parameter for tags, authors, tiers in preview response - Fetch and return theme CSS variables from custom_theme_settings API - Add previewUrlWithParams for member status testing - Implement three preview modes: static, live, member - Add theme presets for Casper, Casper Dark, Edition, Liebling - Add member upsell overlay simulation for member preview mode
When a provider supports native scheduling (like Ghost), the Temporal workflow now posts immediately and lets the provider handle scheduling. This allows scheduled posts to appear in Ghost CMS immediately with 'scheduled' status instead of waiting until the publish date. Changes: - Add supportsNativeScheduling property to SocialAbstract base class - Add supportsNativeScheduling to SocialProvider interface - Set supportsNativeScheduling=true in GhostProvider - Add supportsNativeScheduling activity to check provider capability - Update post workflow to skip sleep for native scheduling providers For Ghost: scheduled posts now appear in the Ghost dashboard immediately as 'scheduled' status, and Ghost handles the actual publishing at the configured time. fixes gitroomhq#1324 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This is an update/supersede of PR #1142 with comprehensive Ghost CMS integration fixes.
Fixes #1142 - Adds native Ghost CMS integration with scheduling, theme management, newsletters, and tiers support.
Original PR #1142 Summary
Additional Features in This PR
Bug Fixes (Critical)
updated_atfield fetching to prevent 409 UPDATE_COLLISION errorsupdated_attimestamp for optimistic concurrency controlupdate()andchangeStatus()now fetch current post before editing to get correctupdated_atchangeDate()to prevent NPE when post doesn't existCode Quality
Testing
Supersedes: #1142