Skip to content

fix: fetch server configuration on client initialization for invite_only servers#152

Open
riscdanger wants to merge 1 commit intostoatchat:mainfrom
riscdanger:invite-only-fix
Open

fix: fetch server configuration on client initialization for invite_only servers#152
riscdanger wants to merge 1 commit intostoatchat:mainfrom
riscdanger:invite-only-fix

Conversation

@riscdanger
Copy link
Copy Markdown

When invite_only: true is set on a Stoat server, the registration form in the web frontend never displays the "Invite Code" input field, making it impossible to register on invite-only instances via the UI.

note: I'm not a typescript dev and this was written by AI.

Thanks :)

Root Cause

The Client constructor in javascript-client-sdk/src/Client.ts initializes configured to true whenever a default configuration is passed in (which Controller.ts always does). The #fetchConfiguration() method then skips fetching the real server config because this.configuration is already truthy.

As a result, features.invite_only was always false (the hardcoded default), so FlowCreate.tsx's <Show when={isInviteOnly()}> never rendered the invite field.

Changes

javascript-client-sdk/src/Client.ts

  • Add #configurationFetched flag to track whether the server config has been fetched
  • Initialize configured signal to false instead of inferring from whether a default config was passed
  • #fetchConfiguration() now always fetches the real server config on first call, then caches

The frontend code in FlowCreate.tsx and Form.tsx was already correct — it just never received the real server config to read invite_only from.

Testing

  • Start a Stoat instance with invite_only: true in Revolt.toml
  • Visit the web frontend registration page — the "Invite Code" field should now appear
  • Submit with a valid invite code — registration should succeed
  • Non-invite-only instances should continue to work as before (no invite field shown)

The Client constructor sets `configured` to true and skips fetching
the real server config when a default configuration is pre-set by
the Controller. This caused `invite_only` and other feature flags
to always reflect hardcoded defaults instead of actual server values.

Introduce a `#configurationFetched` flag to track whether the server
config has been fetched, independent of whether a default config
was provided. The `configured` signal now starts as false and is
set to true only after the real config is retrieved.

Fixes: invite-only registration form not showing the invite code field
Signed-off-by: risc <dev@risc.4wrd.cc>
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