Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

POST /admin/lift lifts a live mute or ban for the owner or a moderator, same-origin, and logs who did it - route and test only #367

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

POST /admin/lift now works. The admin tests pass (17), but I couldn't run the type check: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir". I didn't run the full bun test either.

Notes

shipped merged

opened this

POST /admin/lift now works. The admin tests pass (17), but I couldn't run the type check: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir". I didn't run the full bun test either.

  • Route: the new handleLift in admin-routes.ts takes a form body of kind=mute|ban and id=<user id>.
  • Access: a cross-origin POST, a plain user, or a guest is refused with 403. A moderator needs a verified forge identity, as on /live, and gets 403 trying to lift a mute or ban on a moderator. Only the owner can do that.
  • Errors: a bad kind or id is a 400, and a mute or ban that isn't in force is a 404.
  • Success: it calls chat.unmute or accounts.unban, records unmuted <name> or unbanned <name> in the admin log under the caller, and redirects 303 to /admin.

I also touched relay.ts, which the issue said not to. Without one routing line there, /admin/lift never reaches the handler, so the route would not exist. relay.ts is the only file outside the issue's scope. The new test is in admin-relay.test.ts, which already boots the relay, rather than a separate test file.

The test covers a moderator's unban appearing in the log, a plain user's 403, a cross-origin 403, a bad kind or id giving 400, a missing ban giving 404, and the moderator-on-moderator rule. It also covers the owner lifting mutes.

handleLift imports sameOrigin from relay.ts, which already imports admin-routes.ts, so the two files import each other. It only runs at call time, and the tests pass.

🤖 Generated with Claude Code

Closes #356

commented

POST /admin/lift now works. The admin tests pass (17), but I couldn't run the type check: bun x tsc --noEmit failed here with "bun is unable to write files to tempdir". I didn't run the full bun test either.

  • Route: the new handleLift in admin-routes.ts takes a form body of kind=mute|ban and id=<user id>.
  • Access: a cross-origin POST, a plain user, or a guest is refused with 403. A moderator needs a verified forge identity, as on /live, and gets 403 trying to lift a mute or ban on a moderator. Only the owner can do that.
  • Errors: a bad kind or id is a 400, and a mute or ban that isn't in force is a 404.
  • Success: it calls chat.unmute or accounts.unban, records unmuted <name> or unbanned <name> in the admin log under the caller, and redirects 303 to /admin.

I also touched relay.ts, which the issue said not to. Without one routing line there, /admin/lift never reaches the handler, so the route would not exist. relay.ts is the only file outside the issue's scope. The new test is in admin-relay.test.ts, which already boots the relay, rather than a separate test file.

The test covers a moderator's unban appearing in the log, a plain user's 403, a cross-origin 403, a bad kind or id giving 400, a missing ban giving 404, and the moderator-on-moderator rule. It also covers the owner lifting mutes.

handleLift imports sameOrigin from relay.ts, which already imports admin-routes.ts, so the two files import each other. It only runs at call time, and the tests pass.

🤖 Generated with Claude Code

Approved

Route and test as scoped. The route checks same-origin, then the forge-verified identity (a moderator must be verified, as on /live), then reads the body capped by bytes actually read. kind and id are validated, a missing mute or ban is 404, and a moderator cannot lift on a moderator. The change is logged under the caller. The preview answers 403 to an anonymous cross-origin-less POST. The one-line relay.ts route is justified. Two things next: (1) the terminal door in src/tty.ts (a /lift command) and a README line on how to use it, since both doors must offer it; (2) run bun x tsc --noEmit, which the author could not, because the relay.ts and admin-routes.ts import cycle is only safe at call time and the type check should confirm it. Consider moving sameOrigin to a small module to break the cycle.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs