Skip to content

feat(cms): mark a page published once its WordPress post is put live, read when the Library opens and daily (#1331) - #1570

Merged
gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-wordpress-published
Oct 28, 2026
Merged

gkhngyk merged 8 commits into
ansvisor:mainfrom
cihan-gyk:feature/cms-wordpress-published

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Send to CMS, phase 2 (#1331): WordPress, part 2 of 3: a post put live in WordPress marks its page Published, as #1509 does for Webflow.

Stacked on #1569 (the WordPress connection and send). Review that one first; this PR's own change is its last commit.

Nothing calls back when a WordPress post goes live, so Ansvisor reads the posts its sends made (cms/wordpress-status.js):

  • Which sends: the brand's sends to the connected site (target_collection = its address), still sent, from the last 60 days. Each page's latest send only, newest first.
  • What each post reads as:
    • Published. A send writes only to a draft: a live post gets a new draft (feat(cms): connect a brand's WordPress site with an Application Password and send pages to it as draft posts (#1331) #1569). So a post that's publish now was put live after the send. Its delivery is marked published at the post's own link (markDeliveryPublished, as the webhook callback and Webflow do). The draft becomes Published, its tracking starts (CE-013), and its Publish task completes.
      • A Contributor's post an Editor published: the Contributor can no longer read it to edit (403 rest_forbidden_context), so it's read as the public sees it (context=view). A post it can't read either way stays open, counted as a failed read.
    • Waits: a post that is scheduled (future), pending or still a draft.
    • Closed as "Removed in WordPress": a post in the trash, or gone (404, 410) while the site answers as WordPress. The page's next send makes a new post.
      • A post's 404 closes its send only once the site has answered as WordPress in that check: another post was read, or /wp-json/ lists wp/v2.
      • A site that answers 404 for every post (moved, its permalinks set to Plain, a plugin hiding the route) closes nothing. Its 404s count as failed reads.
    • Sign-in refused: the connection is marked to connect again (as the send read it, updated_at), and the check stops.
    • Failures: three failed reads in a row stop the check (the site is down).
  • When:
    • When the Library opens: POST /api/content-drafts/wordpress-status reads the brand's 10 newest sends. It's for any member, a brand at most every two minutes, as /webflow-status is.
    • Once a day for all brands with WordPress connected, on an active subscription (sweepWordPressPublished, beside Webflow's in the daily run). It reads 100 a brand, in a shuffled order, stopping after 10 minutes.

A post found live by a send (cms/wordpress-delivery.js): a page sent again before the check saw its post published goes as a new draft (#1569). Its last send is now marked published at the post's link, so that publish isn't lost behind the new draft. The page itself follows its latest send, that new draft, once it's published.

Known limit, as with Webflow: a published post moved back to draft in WordPress leaves its page Published, since a published send isn't read again.

The web isn't in this PR. The Library will call /wordpress-status as it calls /webflow-status, alongside the Settings card and the Send dialog's target, in part 3.

Related issue

Part of #1331 (phase 2, WordPress). Stacked on #1569.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd server && npx vitest run src/lib/cms/wordpress-status.test.js src/routes/content-drafts-send.test.js
  2. With a real site (gkhngyk): send a page to WordPress (feat(cms): connect a brand's WordPress site with an Application Password and send pages to it as draft posts (#1331) #1569) and publish the post in WordPress. Then POST /api/content-drafts/wordpress-status { brandId }: the page comes back in published with the post's link, and the Library shows it Published.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Server only: npm run format, npm run lint and npm test (2,967 tests) in server/. I ran them again after the pre-push review's fixes. New cases cover a Contributor's published post, a site that 404s everything, a published link that isn't an address, and another workspace's brand. The first two fail without their fix.

🤖 Generated with Claude Code

cihan-gyk and others added 2 commits October 27, 2026 10:18
…ord and send pages to it as draft posts (ansvisor#1331)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… read when the Library opens and daily (ansvisor#1331)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 27, 2026
…ss-server

# Conflicts:
#	server/src/lib/content-delivery.test.js
#	supabase/schema.sql
cihan-gyk and others added 3 commits October 28, 2026 03:07
… has ended

Since ansvisor#1589 a workspace whose plan has ended can't write, but taking back an
outside account's access stays open (COST_STOPPING), as Webflow's disconnect
does. WordPress's disconnect revokes the Application Password where the site
allows, so it joins the list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

Merged #1569's new head in (da8e326). server.js: main (#1608) moved the three Cloro imports into cloro-callback.js, so they're gone here and sweepWordPressPublished's import stays. Checks: typecheck on every web tip, the server suite at #1579 (3,522 tests), and the whole web suite (4,438 tests) and yarn build at #1580.

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups

Reviewed this PR's own change (#1569's head ddc01c9 → da8e326, read as merged on main cfd8a35). It merges clean on main.

What I checked

  • Which posts are read. Only the brand's sends to the site connected now (target_collection = site_url), sent in the last 60 days, each page's latest send, up to 10 when the Library opens and 100 a brand in the daily sweep. A post is read with the connection's own sign-in, through the same https-only, public-address-only client as #1569.
  • What is marked. A post with status publish marks its send (and the page, when that send is its latest) published at the post's link; the link must be http(s), and the column's own check bounds it. A post in the trash, or gone while the site still answers as WordPress, closes its send as "Removed in WordPress"; a site that answers 404 for every post (moved, permalinks set to Plain) closes nothing (answersAsWordPress). A refused sign-in stops the check and marks the connection, only if it is still the one read.
  • Who can trigger it. POST /content-drafts/wordpress-status checks the brand is in the caller's organization, behind cmsLimiter, and reads a brand at most every two minutes, as Webflow's does.
  • The daily sweep. Active subscriptions only, at most 1,000 connections, shuffled, with a 10-minute deadline checked between brands; one brand's failure is logged and the next goes on. Three failed reads in a row end a brand's check.
  • Send. A send that finds the last post already live marks that send published first, so the publish isn't lost behind the new draft.
  • Tests: full server suite on the merged stack (272 files, 3,773 passed); eslint and prettier clean.

Follow-ups

  1. The deadline is checked between brands only. A site that answers each read slowly but within the 30 s timeout keeps one brand's check going for up to 100 reads (200 when it needs the public read too), so one slow site can hold the sweep well past its 10 minutes and push other brands to the next day. Pass the deadline into checkWordPressPublished and check it between posts, and ask for _fields: 'id,status,link' so a post's full content isn't downloaded just to read its status.
  2. A link over 2,048 characters fails the delivery update and ends that brand's check (the error isn't caught per post). Skip such a link instead.

@gkhngyk
gkhngyk merged commit 6b8a7e8 into ansvisor:main Oct 28, 2026
4 of 5 checks passed
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants