Skip to content

fix(web/classic): use POST /api/channel/:id/status for enable/disable - #5894

Closed
leewaiho wants to merge 1 commit into
QuantumNous:mainfrom
leewaiho:fix/classic-channel-status-api
Closed

fix(web/classic): use POST /api/channel/:id/status for enable/disable#5894
leewaiho wants to merge 1 commit into
QuantumNous:mainfrom
leewaiho:fix/classic-channel-status-api

Conversation

@leewaiho

@leewaiho leewaiho commented Jul 4, 2026

Copy link
Copy Markdown

Problem

PR #5755 (4aee5f7) made the backend reject status in PUT /api/channel/ and migrated the default theme to POST /api/channel/:id/status. The classic theme's manageChannel (web/classic/src/hooks/channels/useChannelsData.jsx) was left using PUT /api/channel/ + body{status}, so enable/disable is broken under classic theme on rc.16+ — the PUT handler returns the status-field interceptor's "invalid params" error.

Fix

Switch classic's enable/disable to the same POST /api/channel/:id/status endpoint used by the default theme. record.status is derived from the target value (1/2) because POST returns {data: changed bool}, not a channel object. priority / weight / enable_all keep PUT (their body has no status field, so they don't trip the interceptor).

Verification

  • Built web/classic on rc.16 base; grepped the minified bundle:
    • API.post("/api/channel/"+id+"/status", {status}) present (enable + disable)
    • old case "disable": data.status=2; API.put("/api/channel/", data) gone
  • End-to-end: deployed the patched classic bundle; under classic theme the disable button now issues POST /api/channel/:id/status and the backend returns {success:true}.

Note (pre-existing, not from this PR)

Classic build on current main is independently broken: web/classic/src/helpers/render.jsx:483 imports SiSlack from react-icons/si, which was removed by f5bba114 chore(web): update default web dependencies. This PR is authored against main but the classic bundle was verified on rc.16 (where it still builds). Happy to send the react-icons fix as a separate PR.

Summary by CodeRabbit

  • Bug Fixes
    • Improved channel enable/disable handling to match the latest backend behavior.
    • Channel status now updates more reliably after enabling, disabling, or making other changes.
    • This helps ensure the channel list shows the correct status after an action completes.

PR QuantumNous#5755 (4aee5f7) rejected `status` in PUT /api/channel/ and migrated
the default theme to POST /api/channel/:id/status, but classic's
manageChannel was left on PUT + body{status}, breaking enable/disable
under classic theme on rc.16+ (backend returns "无效的参数").

Switch enable/disable to the same POST endpoint; derive record.status
from the target value because POST returns {data: changed bool}, not a
channel object. priority/weight/enable_all keep PUT (their body has no
`status` field, so they don't trip the interceptor).
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 108b3a5d-b355-4576-82d4-06bb62075371

📥 Commits

Reviewing files that changed from the base of the PR and between 722d036 and 15e753d.

📒 Files selected for processing (1)
  • web/classic/src/hooks/channels/useChannelsData.jsx

Walkthrough

The manageChannel handler in useChannelsData.jsx was updated so enable/disable actions send POST /api/channel/:id/status with a status payload instead of PUT /api/channel/. The success handler now sets record.status from a precomputed statusAfter value for enable/disable, or from the response data for other actions.

Changes

Channel Status Update Flow

Layer / File(s) Summary
Enable/disable request and status update
web/classic/src/hooks/channels/useChannelsData.jsx
Switches enable/disable requests to POST /api/channel/:id/status with a computed statusAfter payload, and updates the success handler to set record.status from statusAfter (enable/disable) or res.data.data.status (other actions).

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant UI
  participant manageChannel
  participant API

  UI->>manageChannel: trigger enable/disable
  manageChannel->>manageChannel: compute statusAfter
  manageChannel->>API: POST /api/channel/:id/status {status}
  API-->>manageChannel: response
  manageChannel->>manageChannel: set record.status from statusAfter
Loading

Poem

A hop, a skip, a status flip,
POST replaces PUT with a nimble hip!
statusAfter guides the way,
Channels enable, channels stay,
This bunny cheers the tidy trip! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: switching classic channel enable/disable to the POST status endpoint.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@leewaiho leewaiho closed this Jul 9, 2026
@leewaiho
leewaiho deleted the fix/classic-channel-status-api branch July 9, 2026 16:33
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