Skip to content

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Oct 16, 2025

Summary by CodeRabbit

  • Refactor
    • Enhanced room invitation handling by optimizing internal data flow and system architecture to improve code maintainability and efficiency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

The invite processing flow is refactored to accept pre-filtered stripped state events instead of the full member event object. Room privacy checks now inspect strippedStateEvents directly to determine encryption and join rules. The federation controller passes invite_room_state from the request body to the updated service method.

Changes

Cohort / File(s) Summary
InviteService signature updates
packages/federation-sdk/src/services/invite.service.ts
shouldProcessInvite parameter changed from event to strippedStateEvents array; processInvite gains strippedStateEvents parameter and delegates it to shouldProcessInvite. Room privacy logic now inspects stripped state events for encryption and join_rules instead of event.unsigned.invite_room_state.
Federation invite endpoint
packages/homeserver/src/controllers/federation/invite.controller.ts
Passes body.invite_room_state as strippedStateEvents argument to processInvite call. No other behavior changes.

Sequence Diagram

sequenceDiagram
    participant Controller as Federation Controller
    participant Service as InviteService
    
    Note over Controller,Service: Before: event-based processing
    Controller->>Service: processInvite(event, roomId, ...)
    Service->>Service: shouldProcessInvite(event)
    Note over Service: Inspects event.unsigned.invite_room_state
    Service-->>Controller: Accept/Reject
    
    Note over Controller,Service: After: strippedStateEvents-based processing
    Controller->>Service: processInvite(event, roomId, ..., strippedStateEvents)
    Service->>Service: shouldProcessInvite(strippedStateEvents)
    Note over Service: Inspects strippedStateEvents for join_rules & encryption
    Service-->>Controller: Accept/Reject
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit's ode to cleaner streams:

State events stripped, all lean and bare,
No hidden treasures tucked with care,
Privacy rules now crystal clear,
The invitation's truth shines here!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "fix: receive invite_room_state as invite param" directly describes the main change in the changeset. The modifications across both files center on receiving and passing the invite_room_state (strippedStateEvents) as a parameter through the invite processing workflow, which is exactly what the title conveys. The title is concise, clear, and avoids vague language, making it easy for teammates to understand the primary intent of the change when scanning the repository history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-invite-statem-param

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6614719 and f42a459.

📒 Files selected for processing (2)
  • packages/federation-sdk/src/services/invite.service.ts (2 hunks)
  • packages/homeserver/src/controllers/federation/invite.controller.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/federation-sdk/src/services/invite.service.ts (1)
packages/room/src/types/_common.ts (1)
  • PduForType (26-26)
🔇 Additional comments (3)
packages/federation-sdk/src/services/invite.service.ts (3)

152-184: LGTM! Privacy checks correctly use stripped state events.

The refactored privacy checks correctly inspect the strippedStateEvents array to determine room encryption and join rules. The use of .some() is appropriate for checking if any event matches the criteria.

Note: If strippedStateEvents is empty, both isRoomNonPrivate and isRoomEncrypted will be false, meaning the invite will be processed. Ensure this behavior aligns with your security requirements.


186-200: LGTM! Method signature correctly updated.

The processInvite method signature correctly adds the strippedStateEvents parameter, maintaining type consistency with shouldProcessInvite.


203-203: LGTM! Correct delegation to shouldProcessInvite.

The call correctly passes the strippedStateEvents parameter to shouldProcessInvite.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.49%. Comparing base (6614719) to head (f42a459).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #286   +/-   ##
=======================================
  Coverage   60.49%   60.49%           
=======================================
  Files          67       67           
  Lines        6675     6675           
=======================================
  Hits         4038     4038           
  Misses       2637     2637           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggazzo ggazzo merged commit a3a71cd into main Oct 16, 2025
2 of 3 checks passed
@ggazzo ggazzo deleted the add-invite-statem-param branch October 16, 2025 13:06
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.

3 participants