feat: implement group join via invite code API (#111)#138
Merged
SudiptaPaul-31 merged 1 commit intoApr 26, 2026
Merged
Conversation
Adds POST /api/groups/:id/invite to generate UUID-based invite codes with optional time-based (expires_in) and usage-based (max_uses) expiry, and POST /api/groups/join to validate and consume a code, adding the user to room_members. Invite use_count is incremented atomically via a PostgreSQL RPC function to avoid race conditions. Includes migration 011 which adds max_uses/use_count columns to the invites table, required RLS policies for authenticated read/update, and the increment_invite_use_count SQL function. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@patopatrish Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full invite code flow for joining groups, closing #111.
POST /api/groups/:id/invite— generates a UUID-based invite code for a group, with optional time-based (expires_in) and usage-based (max_uses) expiryPOST /api/groups/join— validates an invite code and adds the authenticated user to the group's membership011enhances theinvitestable with usage tracking and adds an atomic PostgreSQL RPC for incrementing use counts without race conditionsWhat changed
New files
lib/groups/invite.tsapp/api/groups/[id]/invite/route.tsPOST /api/groups/:id/invite— generate invite codeapp/api/groups/join/route.tsPOST /api/groups/join— join group via invite codescripts/011_enhance_invites_for_group_join.sqlmax_uses,use_count, RLS policies, andincrement_invite_use_countSQL functionModified
scripts/MIGRATIONS_README.md— documents migration 011 and psql apply commandAPI reference
Generate invite code
Join via invite code
DB migration
Apply after existing migrations:
psql "$DATABASE_URL" -f scripts/011_enhance_invites_for_group_join.sqlChanges to
public.invites:max_uses INTEGER(nullable, unlimited when null)use_count INTEGER NOT NULL DEFAULT 0increment_invite_use_count(invite_code text)asSECURITY DEFINERfor atomic updatesroom_idandcreated_byAcceptance criteria checklist
expires_in)max_uses)lib/groups/invite.ts