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

Migrated from github.com/Trevato/SO-ARM100

A moderator can ban and unban over /live, never the owner or another moderator, and receives the banned list #327

Merged opened this

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

Merged

A verified moderator can now send ban with on true or false over /live. A moderator who tries it on the owner or another moderator gets an error and nothing changes. The new test and the rest of src/lobby.test.ts pass (37 of 37).

Notes

shipped merged

opened this

A verified moderator can now send ban with on true or false over /live. A moderator who tries it on the owner or another moderator gets an error and nothing changes. The new test and the rest of src/lobby.test.ts pass (37 of 37).

The full bun test has two failures, in the viewer page's first-visit size budget and in the model-routes test. They fail the same way without my change. I couldn't run the type check here: bun x tsc --noEmit stops with "bun is unable to write files to tempdir".

  • Moves into banUser: the owner's ban code moved out of the switch in src/lobby.ts into a new banUser method. The owner and moderators now share it, and the log still says who banned or unbanned.
  • Moderator limits:

- A moderator who bans the owner or a moderator gets "only the owner can ban the owner or a moderator". - The same goes for lifting the ban on someone whose name is a moderator's. - A plain user still gets "only the owner can do that".

  • Banned list: moderators now get banned when they join and on every change, as owners do. Moderators who are already connected get it through mayHearMuted, the existing check that decides who gets the muted list.
  • Test: the new one in src/lobby.test.ts has a moderator ban and unban a user, with the ban barring the user and the log naming the moderator. It also checks the refusals against the owner, another moderator and a plain user.
  • Distinct addresses: the test gives alice and carol their own x-forwarded-for addresses. A ban also bars the banned person's address, and without that every test client shares one address.

forge.json is untouched.

🤖 Generated with Claude Code

Closes #227

commented

A verified moderator can now send ban with on true or false over /live. A moderator who tries it on the owner or another moderator gets an error and nothing changes. The new test and the rest of src/lobby.test.ts pass (37 of 37).

The full bun test has two failures, in the viewer page's first-visit size budget and in the model-routes test. They fail the same way without my change. I couldn't run the type check here: bun x tsc --noEmit stops with "bun is unable to write files to tempdir".

  • Moves into banUser: the owner's ban code moved out of the switch in src/lobby.ts into a new banUser method. The owner and moderators now share it, and the log still says who banned or unbanned.
  • Moderator limits:

- A moderator who bans the owner or a moderator gets "only the owner can ban the owner or a moderator". - The same goes for lifting the ban on someone whose name is a moderator's. - A plain user still gets "only the owner can do that".

  • Banned list: moderators now get banned when they join and on every change, as owners do. Moderators who are already connected get it through mayHearMuted, the existing check that decides who gets the muted list.
  • Test: the new one in src/lobby.test.ts has a moderator ban and unban a user, with the ban barring the user and the log naming the moderator. It also checks the refusals against the owner, another moderator and a plain user.
  • Distinct addresses: the test gives alice and carol their own x-forwarded-for addresses. A ban also bars the banned person's address, and without that every test client shares one address.

forge.json is untouched.

🤖 Generated with Claude Code

commented

I merged main into this branch and pushed it. The lobby tests pass (40), but I couldn't run the type check here.

bun x tsc --noEmit failed with "bun is unable to write files to tempdir: ReadOnlyFileSystem". I didn't run bun install first, so there's no local tsc either. The forge's check will cover the type check on this push.

The conflicts were in Software/so101/src/lobby.ts and lobby.test.ts. I kept both sides in each:

  • Doc comment: it now lists both banned (owners and moderators) and reports.
  • seat(): anyone allowed to see the muted list now also gets the reports list and the banned list on join. words and the admin state stay owner-only.
  • Tests: the moderator ban/unban test and the report test both stay.

🤖 Generated with Claude Code

Approved

Verified moderators can ban and unban over /live and receive the banned list. Moderator status is checked by seat.verified plus isModerator, so it does not come from a client-typed name. Banning the owner or another moderator is refused, and so is lifting the ban on one. A plain user is still refused. Each ban or unban is logged with who did it, and the shared banUser removes the duplicated owner code. The new test covers ban, unban, the log, the banned list and every refusal. The preview answers 200 on /. I did not exercise ban over a live socket there, because that needs a signed-in moderator.

Two things to do next:

  1. Software/README.md (around lines 466-491) still says the ban list and unban are the owner's. Add that moderators can ban and unban over /live, except the owner and other moderators.
  2. The page UI was not changed, so a moderator receives the banned list but has no control for it. Wire that up in a follow-up only if the issue asks for it. The change is otherwise scoped to the issue.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs