Skip to content

Create and configure rooms from a spec, and never create one on a join - #4279

Merged
jcbrand merged 5 commits into
masterfrom
feat/rooms-create
Nov 29, 2026
Merged

jcbrand merged 5 commits into
masterfrom
feat/rooms-create

Conversation

@jcbrand

@jcbrand jcbrand commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Lets a groupchat be created and configured from a spec, so an installer (such as Kronik's) can set up the rooms its agents use, with the user as the owner.

Daemon

  • rooms.create creates a room with the given settings and affiliations, then joins it. A room that already exists is left as it is (created: false).
  • rooms.config returns a room's settings, affiliation lists and form fields. rooms.configure changes settings and gives affiliations: it promotes but never demotes or bans someone with an affiliation, and lifts a ban only for JIDs in unban. A JID left as it is comes back in kept, and dry_run reports the changes only.
  • All three need full access, so agents on restricted connections can't create or reconfigure rooms.
  • A join never creates a room any more. Before, muc_instant_rooms let a join recreate a room that had disappeared, with the server's defaults (not members-only, not persistent). Now the join fails with NOT_FOUND, and a members-only refusal comes back as JOIN_REFUSED with the server's reason.
  • New FORBIDDEN error, for a room we don't own.

CLI

  • converse rooms create <room>, converse rooms config show <room> and converse rooms config set <room>.
  • The room's spec is read from ~/.config/converse/rooms/<jid>.json ({"settings": {...}, "affiliations": {...}}) when no --file is given. --set name=value and --member jid add to it.
  • config set with no flags brings the room in line with its spec, and --dry-run shows what would change.
  • config set --unban <jid> lifts a ban. A ban the spec alone would lift is asked about at a terminal, and kept without one.
  • rooms join on a missing room asks at a terminal before creating it, and --create creates it without asking. Without a terminal it exits 3.
  • Commands can now be three words long. FORBIDDEN maps to exit code 10.

Headless

The protocol work lives here, so the web app and other front ends get the same behaviour as the daemon, which only checks its parameters and maps errors.

  • New api.rooms.config.get(jid) and api.rooms.config.set(jid, settings, { dry_run, force }). Settings are checked against the room's owner form, and if any isn't one of its fields, or has a value the field doesn't take, a RoomSettingsError is thrown and nothing is sent.
  • New api.rooms.exists(jid) and api.rooms.destroy(jid, { reason, new_jid }). MUC.sendDestroyIQ() uses the latter.
  • New api.rooms.affiliations.fetch(jid), the lists we may see, and api.rooms.affiliations.grant(jid, lists, { unban, dry_run }), which promotes but never demotes, bans only JIDs without an affiliation, and lifts a ban only for JIDs in unban.
  • auto_configure goes through api.rooms.config.set. A roomconfig setting the server doesn't have used to be dropped silently, which could leave a room meant to be members-only open. Now nothing is set and the configuration form is shown. A false given as a string is no longer taken for true.
  • New overridable MUC.onCreated(), called when we've just created a room (status 201). The daemon overrides it to fill in the owner form.
  • api.rooms.get creates new rooms with the chatboxes registry's class, as restored rooms already were.
  • StanzaError keeps the error's text, as text.

Tests

  • src/daemon/tests/room-setup.prosody.js and src/cli/tests/rooms.prosody.js run against a real Prosody (npm run test:prosody). The existing Prosody tests now create their rooms explicitly.
  • Headless: 733 pass. Web: 1247 pass. Daemon and CLI: 565 pass. Prosody: 46 of 47 pass; the file upload test failed only because the container running it couldn't reach Prosody's upload URL. oxlint and tsc are clean.

@jcbrand
jcbrand force-pushed the feat/rooms-create branch 3 times, most recently from 09b1193 to 37d4927 Compare November 29, 2026 09:02
@jcbrand
jcbrand marked this pull request as ready for review November 29, 2026 12:59
…the registry's class

onCreated() handles a room we've just created (status 201), so a subclass
can configure it its own way. api.rooms.get now creates new rooms with the
class in the chatboxes registry, as restored rooms already were, so the
subclass is used for both.
@jcbrand
jcbrand force-pushed the feat/rooms-create branch 2 times, most recently from 0e3a55b to 4c8b05d Compare November 29, 2026 15:36
…e one on a join

- rooms.create creates a room with the given settings and affiliations, and
  leaves a room that exists as it is. rooms.config shows a room's settings and
  affiliations, and rooms.configure changes them, adding affiliations only.
  All three need full access.
- A join no longer creates a room with the server's defaults. It fails with
  NOT_FOUND, and a members-only refusal is reported as JOIN_REFUSED.
- The CLI adds rooms create, rooms config show and rooms config set. They read
  the room's spec from ~/.config/converse/rooms/<jid>.json when no --file is
  given. rooms join asks at a terminal before creating a missing room, or
  creates it with --create.
- New FORBIDDEN error (exit code 10) for a room we don't own.
@jcbrand
jcbrand merged commit cb3ecf1 into master Nov 29, 2026
6 checks passed
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