Feature: Invites #12
Labels
No labels
area:api
area:core
area:docs
area:infra
area:ux
dependencies
documentation
duplicate
good first issue
help wanted
invalid
question
rust
status:complete
status:partial
status:planned
type:bug
type:design
type:feature
type:infra
type:refactor
type:research
type:ux
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
icub3d/decentcom#12
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated from GitHub issue icub3d/decentcom#12
Original Author: @icub3d
Original Date: 2026-04-15T14:15:34Z
Feature: Invites
Overview
Invite links allow server members to bring new users into the community. Invites can be single-use or multi-use, time-limited or permanent, and can optionally grant a role on join. This is the primary mechanism for growing a server's membership and is required by the
invite_onlymembership mode.Background
The server model design doc (
docs/design/server-model.md) defines invite links as the primary discovery and joining mechanism. Invite links encode the server address and an invite token. They can be single-use, multi-use, time-limited, channel-specific, or role-granting. This feature depends on roles (#11) being implemented so that role-granting invites work and themanage_invitespermission flag is available.Requirements
manage_invitespermission can generate invite linksmanage_invitescan list all active invites and see usage countsmanage_invitescan revoke (delete) any inviteinvite_onlymodeDesign
API / Interface Changes
REST endpoints (all under
/api/v1/):/invitesmanage_invites/invitesmanage_invites/invites/:code/invites/:codemanage_invites/invites/:code/joinPOST
/invitesrequest body:POST
/invites/:code/joinresponse:GET
/invites/:coderesponse (public):Gateway events:
MEMBER_JOIN— broadcast when a user joins via invite (includes member info and roles)Invite link format:
The client intercepts this URL scheme and initiates the join flow.
Data Model Changes
New table:
Component Changes
Server (
server/):server/src/models/invite.rs— Invite struct and creation parametersserver/src/store/invite_store.rs—InviteStoretrait added to the storage trait hierarchyserver/src/store/sqlite/invite_store.rs— SQLite implementationserver/src/routes/invites.rs— REST handlers for invite CRUD and joinserver/src/utils/code.rs— Utility to generate short, URL-safe invite codes (e.g.,nanoidorrandwith a Base62 alphabet)server/src/routes/mod.rs— Register invite routesserver/src/store/mod.rs— AddInviteStoreto storage traitClient (
client/):client/src/api/invites.ts— API client functions for invite endpointsclient/src/stores/invites.ts— Zustand slice for invite management stateclient/src/components/invites/CreateInviteDialog.tsx— Modal for generating invites with options (max uses, expiry, role grant)client/src/components/invites/InviteList.tsx— Table of active invites with usage stats and revoke buttonclient/src/components/invites/JoinByInvite.tsx— UI for joining a server via an invite link (shows server preview, join button)client/src/hooks/useInviteLink.ts— Hook to parse invite URLs and extract code + server addressDatabase migrations:
server/migrations/NNNN_create_invites.sqlImplementation Notes
InviteStoretrait follow the existing module layout (storage/models.rs,storage/traits.rs,storage/sqlite/invites.rs).server/src/invites/mod.rs(generate_code()— 8 Base62 chars viarand).consume_inviteis atomic: UPDATE with all validity conditions in the WHERE clause; a follow-up SELECT disambiguates NotFound vs exhausted/expired.invite_onlymode, user account creation is now permitted (so users can auth before using an invite); full membership gating is deferred to Feature 13.POST /invitesreturnsinvite_linkbuilt from the configured bind address and generated invite code.everyonerole if missing, then applies optionalgrant_role_id.MEMBER_JOINgateway events are emitted on successful invite joins.Task List
Server
server/src/storage/models.rsInviteStoretrait to the storage trait hierarchyinvitestableInviteStorefor the SQLite backend/inviteshandler (create invite, permission check)/inviteshandler (list all invites, permission check)/invites/:codehandler (public invite preview, returns server name and member count)/invites/:codehandler (revoke invite, permission check)/invites/:code/joinhandler: validate invite (not expired, not exhausted), assign grant role, increment use_count, broadcast MEMBER_JOIN via gatewayinvite_onlymode user creation is allowed; access gating deferred to Feature 13Client
decentcom://orhttps://invite URL scheme in the Tauri app (deep link registration)Test List
Open Questions