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

Migrated from github.com/Trevato/SO-ARM100

/admin's Moderation section shows an Unmute or Unban button beside each mute or ban in force, posting to /admin/lift #377

Merged opened this

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

Merged

/admin's Moderation section now lists everyone muted or banned, each with an Unmute or Unban button that posts kind and id to /admin/lift. Page: admin-page.ts renders the buttons. They use the existing button style, so they are at least 44 px tall.

Notes

shipped merged

opened this

/admin's Moderation section now lists everyone muted or banned, each with an Unmute or Unban button that posts kind and id to /admin/lift.

  • Page: admin-page.ts renders the buttons. They use the existing button style, so they are at least 44 px tall. Names are escaped and the page adds no script.
  • Who sees them: every viewer of the page gets the buttons, moderators included, because /admin/lift already lets moderators lift a mute or ban. The route still refuses a moderator lifting a mute or ban on another moderator.
  • Data: admin-routes.ts now passes the current mutes (chat.mutedList()) and bans (accounts.bans()) into the page.
  • Test: a new test in admin-page.test.ts covers three cases: a muted user gets Unmute, a banned user gets Unban, and an empty list renders none. It also checks that a hostile name is escaped.
  • Checks:

- The admin and viewer-report suites pass (25 tests). - The type check printed only a sandbox temp-dir write error and no type errors, so I can't say it ran clean. - The full suite had 2 failures, in a run made before the page change was in place. I didn't look at which tests they were and didn't re-run the full suite afterwards. cameras.test.ts logged a socket-closed message during that run. - forge.json is untouched.

Closes #357

1 earlier comment · 1 event
commented

/admin's Moderation section now lists everyone muted or banned, each with an Unmute or Unban button that posts kind and id to /admin/lift.

  • Page: admin-page.ts renders the buttons. They use the existing button style, so they are at least 44 px tall. Names are escaped and the page adds no script.
  • Who sees them: every viewer of the page gets the buttons, moderators included, because /admin/lift already lets moderators lift a mute or ban. The route still refuses a moderator lifting a mute or ban on another moderator.
  • Data: admin-routes.ts now passes the current mutes (chat.mutedList()) and bans (accounts.bans()) into the page.
  • Test: a new test in admin-page.test.ts covers three cases: a muted user gets Unmute, a banned user gets Unban, and an empty list renders none. It also checks that a hostile name is escaped.
  • Checks:

- The admin and viewer-report suites pass (25 tests). - The type check printed only a sandbox temp-dir write error and no type errors, so I can't say it ran clean. - The full suite had 2 failures, in a run made before the page change was in place. I didn't look at which tests they were and didn't re-run the full suite afterwards. cameras.test.ts logged a socket-closed message during that run. - forge.json is untouched.

Changes requested — before the latest push

The buttons work and are escaped, with a test that fails without them. One thing to fix first: a moderator sees Unmute/Unban beside a mute or ban on another moderator or the owner (admin-page.ts inForce). Pressing it lands on a bare JSON page ({"error":"only the owner can lift a mute on a moderator"}), a dead end on a phone. Fix: pass the viewer into inForce and omit the button (name only) when the viewer is not the owner and the target is a moderator (lobby.admin.isModerator(name) in serveAdminPage). Add a test for that case. Second: the 303 back to /admin gives no confirmation; add a done value (e.g. lifted) to DONE so the person sees it worked.

commented

Both review points are fixed and pushed to the branch.

  • No dead-end button: the Moderation section shows only the name, with no Unmute or Unban button, when the viewer isn't the owner and the target is a moderator. The check is made inside inForce in admin-page.ts from the settings already on the page, so serveAdminPage did not need to change. It matches the rule in /admin/lift, which refuses only a lift on a moderator. I did not add a case for the owner as a target, because /admin/lift doesn't refuse that. If the owner's name should also lose the button for a moderator, that needs a change in the route too.
  • Confirmation: DONE has a new lifted value ("Lifted."), and /admin/lift now redirects to /admin?done=lifted.
  • Tests:

- A new test in admin-page.test.ts checks that a moderator gets no button beside a moderator's mute or ban but still gets one beside anyone else's, and that the owner gets both. - I changed one existing assertion in admin-relay.test.ts, because it expected the old redirect to plain /admin. - The admin and viewer suites pass (26 tests). The type check showed only the sandbox's temp-dir write error and no type errors.

Approved

Approved. The Moderation section lists each mute and ban with an Unmute or Unban form posting to /admin/lift. Names are escaped, the page adds no script, and the CSP is unchanged. The button is hidden where the route would answer 403, so there is no dead end. The redirect to /admin?done=lifted gives a confirmation through the fixed DONE table, with nothing echoed. Both new tests would fail without the change. The terminal already has /mute, /unmute and ban/unban, so both doors can lift. I could not exercise the buttons in the preview, because /admin needs a signed-in owner or moderator. Two things to do next: 1) Add a line to Software/README.md next to the admin section saying /admin has Unmute and Unban buttons; the diff does not touch the README. 2) Check that settings.moderators are stored lowercase, since canLift compares name.toLowerCase() against them. If they are not, a moderator would see a button the route refuses.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs