Skip to content

fix(content): apply the managers' publishing switch to Send to CMS - #1894

Closed
gkhngyk wants to merge 1 commit into
mainfrom
feature/publishing-switch-cms-send
Closed

gkhngyk wants to merge 1 commit into
mainfrom
feature/publishing-switch-cms-send

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Settings › Chat has an Admin switch under What Managers may take live: turning Publishing off for Managers (chat_settings.manager_execute_off, migration 00401). Until now only Chat read it, so a Manager could still send the same page from the Content Editor or the Library. This PR makes Send to CMS respect the switch too.

  • POST /api/content-drafts/send (server): after the existing admin/manager role check, a Manager is refused with 403 and code execute_off when the brand's workspace has publishing in manager_execute_off. Admins skip the read. If the setting can't be read, the send is refused (502 failed), the same fail-closed behavior Chat's send uses. Roles below Manager were already refused (forbidden), and that doesn't change.
  • Web: execute_off is now one of the known send errors in cms-send-client.ts, so the editor's Send dialog and the Library's bulk send dialog show "An admin turned publishing off for managers, so only an admin can send pages to the CMS." instead of a general failure.
  • The Settings › Chat note under What Managers may take live now says that turning Publishing off also stops a Manager's Send to CMS in the Content Editor and Library.
  • Help: help/content/send-to-cms.md says Managers can send only while Publishing is on for them.

Other paths checked: the MCP and internal "mark published" endpoints only record a live URL that already exists (open to any member, and nothing goes to a CMS). Opportunity and task "send to webhook" hand work to a workflow and don't send drafts to a CMS. Neither path changes. The Send button stays visible: the editor and Library don't gate it by role today, so the refusal message comes from the server.

Related issue

Follow-up to #1868 (Chat's CMS send checks the same switch). This PR doesn't depend on it, because the switch already exists on main.

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. As an Admin, go to Settings › Chat › What Managers may take live and switch Publishing off.
  2. As a Manager in that workspace, open a page in the Content Editor and click Send to CMS › Send. The dialog says an admin turned publishing off for managers, and nothing is sent.
  3. As the Manager, in the Library, tick two pages and click Send to CMS. You get the same message.
  4. As the Admin, send the same page. It goes through.
  5. Switch Publishing back on. The Manager's send goes through.
  6. Automated: server: npx vitest run src/routes/content-drafts-send.test.js (Manager-off, Manager-on, Admin-off, and a failed read). web: npx vitest run src/lib/content/cms-send-client.test.ts src/components/content/send-to-cms-dialog.test.tsx "src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx".

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
  • Help article updated under help/ (or no user-visible change) — see help/README.md

🤖 Generated with Claude Code

The Send to CMS route now refuses a manager when an admin turned Publishing off for managers in Settings › Chat (chat_settings.manager_execute_off), with the code execute_off, as Chat's own send does. Admins are unaffected; a failed read of the switch refuses the send. The editor's and Library's send dialogs show the reason, the Settings › Chat note and the Send to CMS help page say the switch covers these sends.
gkhngyk pushed a commit that referenced this pull request Nov 4, 2026
…tly routes to admins and managers

A re-audit of the server's write routes on 2026-11-03 found 15 that start
paid or AI work, delete, or decide for the workspace without a role check.
Each now refuses an analyst or an agency partner with 403 forbidden before
anything runs, is queued, bought or deleted:

- tracking: /check, /analyze-new (Run now) and stopping a run;
- volumes: /analyze, /analyze-batch, /bootstrap, /refresh;
- audits: deleting one;
- competitors: /suggest;
- brand facts: reading the site again, approving or rejecting a fact;
- prompts: /from-topics;
- content: sending opportunities to the webhook, one or in bulk;
- Action Center: Regenerate tasks (a model writes them).

allowRole() in lib/access.js answers the 403 itself, for routes whose catch
answers 500. Reading volumes, the reports summary, the Fan-out tab's
intents and publishing (#1894) stay as they are.

The web hides what the server now refuses: Run All and Test Single Prompt,
stopping a run, the volume buttons, Analyze Prompts, an audit's delete,
Send to Workflow and Send All (and so the bulk boxes), Regenerate tasks,
and the Brand facts tab's Approve, Reject and Read again, with a line on
who does it. The Help articles say who can.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk pushed a commit that referenced this pull request Nov 4, 2026
…s why it is open

routes/write-roles.test.js reads every POST, PUT, PATCH and DELETE route
mounted in routes/index.js (the signed-in person's /api) and fails when its
handler calls no role check: assertRole() or allowRole(), a roles list
such as MANAGER_ROLES, a read of profile.role, or a function of its own
route file (or one it imports from another route file) that does one.

Routes open to every member are listed in OPEN, each with its reason:
Action Center work, running a Site Audit, Content Editor writing, reads
such as the Fan-out tab's intents and the reports summary, the demo brand,
and publishing, whose rule #1894 decides. A listed route that checks the
role, or is gone, fails too, so the list stays true. The webhooks,
callbacks, beacon and internal endpoints are mounted in server.js and
answer to a secret or a signature, so they aren't read.

CONTRIBUTING.md gets a Roles section: who does what, and what a new write
route needs.

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

gkhngyk commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main already covers this. The Content Editor and Library sends check the Managers' publishing switch in cms-send.ts, and publish-cms checks it on the server.

@gkhngyk gkhngyk closed this Nov 6, 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.

1 participant