Skip to content

fix: Invite to Room now creates a pending invitation instead of adding member directly (#3239) - #3269

Open
aaniya22 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
aaniya22:fix/3239-invite-to-room-pending-flow
Open

fix: Invite to Room now creates a pending invitation instead of adding member directly (#3239)#3269
aaniya22 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
aaniya22:fix/3239-invite-to-room-pending-flow

Conversation

@aaniya22

Copy link
Copy Markdown
Contributor

Summary

The "Invite to Room" feature previously added a GitHub user as a full room member immediately, with no consent step. This PR introduces a proper pending-invitation flow: invites create a room_invitations record and notify the invitee, who must accept before becoming a member.

Closes #3239


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • 🔒 Security fix

What Changed

  • Added room_invitations table (migration + schema.sql) with pending/accepted/declined status and RLS policy
  • src/app/api/rooms/[roomId]/invite/route.ts now creates a pending invitation and sends a notification, instead of calling addRoomMember directly
  • Added GET /api/room-invitations to list a user's pending invitations
  • Added POST /api/room-invitations/[invitationId] to accept or decline an invitation
  • Added src/components/rooms/PendingInvitations.tsx, surfaced on the rooms list page
  • InviteModal now shows a pending-confirmation message instead of optimistically closing
  • MembersPanel no longer adds the invited user to the members list on invite, since they aren't a member until they accept
  • Added RoomInvitation type in src/types/rooms.ts

How to Test

  1. Log in as User A, create a room, and invite User B by GitHub username
  2. Confirm User B is not immediately added as a member, and receives a notification
  3. Log in as User B, go to the Rooms page, and confirm the invitation appears under "Pending Invitations"
  4. Accept the invitation and confirm User B is now a room member with access to chat history
  5. Repeat and decline instead — confirm User B is not added as a member

Expected result: Inviting a user creates a pending invitation and notification; the invited user must explicitly accept before becoming a room member.


Screenshots / Recordings

N/A — can add if requested during review.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

  • Keyboard navigation works correctly
  • Color contrast meets WCAG AA standard
  • ARIA labels / roles added where needed
  • Tested on mobile / responsive layout

Additional Context

This is a schema change requiring a new migration (supabase/migrations/20260729041910_add_room_invitations.sql) to be applied before merge. No automated tests were added for the new invitation flow yet — existing rooms.test.ts and rooms-messages.test.ts (16 tests) still pass unaffected. Happy to add coverage for the accept/decline endpoints if desired before merge.

…g member directly (Priyanshu-byte-coder#3239)

- Added room_invitations table (migration + schema.sql) with pending/
  accepted/declined status
- invite/route.ts now creates a pending invitation and notifies the
  invitee, instead of calling addRoomMember directly
- Added GET /api/room-invitations to list a user's pending invitations
- Added POST /api/room-invitations/[invitationId] to accept or decline
- Added PendingInvitations component, surfaced on the rooms list page
- InviteModal now shows a pending-confirmation state instead of
  optimistically closing
- MembersPanel no longer adds the invited user to the members list on
  invite, since they aren't a member until they accept

Signed-off-by: aaniya22 <aaniyaatomar@gmail.com>
@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jul 28, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: "Invite to Room" Immediately Adds Users Instead of Sending an Invitatio

1 participant