Skip to content

Conversation

@sampaiodiego
Copy link
Member

@sampaiodiego sampaiodiego commented Dec 16, 2025

Proposed changes (including videos or screenshots)

Issue(s)

FB-152

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Option to force creation of a new direct message room (bypassing lookup)
  • Improvements

    • Better support for federated DM flows; federated DMs can be invited and now assign owner role to creator
    • DM naming now respects invite/pending statuses and syncs on invite/join/leave
    • Subscription creation can include role assignments
    • Public API/types updated to accept the new options and roles
  • Tests

    • Expanded end-to-end DM/federation tests and generalized direct-URL assertions

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 16, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Dec 16, 2025

⚠️ No Changeset found

Latest commit: aa6dbc8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 16, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a forceNew option to direct-room creation to optionally skip existing-room lookup, adjusts federated direct-room invite handling to allow federated DMs and synchronize DM names on invite/join/leave, propagates subscription roles and status-aware name updates, and updates types and e2e tests accordingly.

Changes

Cohort / File(s) Change Summary
Direct Room Creation
apps/meteor/app/lib/server/functions/createDirectRoom.ts
Added forceNew?: boolean to options to skip existing direct-room lookup when true; removed deprecated derived _id; when room is federated, assign owner role to the creator in per-member subscription upserts.
Add Users / Invitation Logic
apps/meteor/app/lib/server/methods/addUsersToRoom.ts
Relaxed direct-room invitation guard so only non-federated direct rooms are blocked; federated direct rooms can be invited.
Room Service / Subscriptions
apps/meteor/server/services/room/service.ts
createUserSubscription gains optional roles parameter and conditionally includes roles, fname, name, and status; updateDirectMessageRoomName now projects status and skips INVITED subscribers when computing DM name.
Type Definitions
packages/core-services/src/types/IRoomService.ts
ICreateRoomOptions now allows forceNew?: boolean and boolean values in options map; createUserSubscription param includes optional roles?: ISubscription['roles'].
Federation Matrix Member Handling
ee/packages/federation-matrix/src/events/member.ts
Use forceNew: true when creating rooms for invites; derive roomType = 'd' from content.is_direct or missing matrix room name; set DM naming to sender for DMs; call Room.updateDirectMessageRoomName after invite/join/leave and after DM creation.
Federation Matrix Core
ee/packages/federation-matrix/src/FederationMatrix.ts
Non-functional whitespace change in handleInvite.
E2E Tests (Direct URL expectations)
apps/meteor/tests/e2e/create-direct.spec.ts, apps/meteor/tests/e2e/e2e-encryption/e2ee-otr.spec.ts
Relaxed direct-URL assertions to match /direct\/.*/ instead of exact username-based path.
Federation E2E DM Tests & Helpers
ee/packages/federation-matrix/tests/end-to-end/dms.spec.ts, apps/meteor/tests/data/rooms.helper*
Added addUserToRoom helper, removed getSubscriptions export; expanded tests for multi-user/group DM flows, invite/join/leave name sync, and concurrent invite/join handling.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Matrix as Matrix Bridge
    participant MemberEvt as Federation Member Event
    participant CreateDM as createDirectRoom
    participant RoomSvc as RoomService
    participant DB as Database

    Matrix->>MemberEvt: inbound invite event
    MemberEvt->>CreateDM: createDirectRoom(members, { forceNew: true, ... })
    CreateDM->>DB: skip existing-room lookup (forceNew)
    CreateDM->>DB: insert new direct room
    DB-->>CreateDM: created room (_id)
    CreateDM->>RoomSvc: createUserSubscription(member, { roles?, status?, inviter? })
    RoomSvc->>DB: upsert subscription (include roles/fname/name/status as provided)
    DB-->>RoomSvc: subscription persisted
    alt member is federated creator
        RoomSvc->>DB: set owner role on member subscription
        DB-->>RoomSvc: roles updated
    end
    RoomSvc->>RoomSvc: updateDirectMessageRoomName(roomId)
    RoomSvc->>DB: query active members excluding INVITED
    DB-->>RoomSvc: active members
    RoomSvc->>DB: update room fname/name
    DB-->>RoomSvc: room updated
    RoomSvc-->>MemberEvt: notify completion
    MemberEvt-->>Matrix: acknowledge invite handling
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay extra attention to:
    • ee/packages/federation-matrix/src/events/member.ts — DM detection and multiple post-event DM-name sync points.
    • apps/meteor/app/lib/server/functions/createDirectRoom.tsforceNew semantics and federated-owner role assignment in subscription upserts.
    • apps/meteor/server/services/room/service.ts — propagation of roles, conditional subscription fields, and INVITED exclusion when computing DM name.
    • E2E tests changes in ee/.../dms.spec.ts — helper API modifications and concurrent flows.

Possibly related PRs

Suggested labels

stat: ready to merge

Suggested reviewers

  • ggazzo
  • rodrigok

Poem

🐰 I hopped through code to make things new,
ForceNew rooms where old checks flew,
Federated friends keep names in line,
INVITED waits till members sign,
A tiny hop — DM syncs shine true. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'fix(federation): update group DMs names' directly matches the primary change of updating group DM names after user joins/leaves events in federated environments.
Linked Issues check ✅ Passed The PR implements the core requirement from FB-152 by adding DM room name synchronization after inviting, joining, and leaving events in federated contexts.
Out of Scope Changes check ✅ Passed Changes include necessary supporting modifications: forceNew parameter for direct room creation, federated DM invitation handling, roles assignment in federated DMs, and test updates to validate the new behavior.

📜 Recent review details

Configuration used: Organization 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 a299092 and aa6dbc8.

📒 Files selected for processing (9)
  • apps/meteor/app/lib/server/functions/createDirectRoom.ts (3 hunks)
  • apps/meteor/app/lib/server/methods/addUsersToRoom.ts (2 hunks)
  • apps/meteor/server/services/room/service.ts (5 hunks)
  • apps/meteor/tests/e2e/create-direct.spec.ts (1 hunks)
  • apps/meteor/tests/e2e/e2e-encryption/e2ee-otr.spec.ts (1 hunks)
  • ee/packages/federation-matrix/src/FederationMatrix.ts (1 hunks)
  • ee/packages/federation-matrix/src/events/member.ts (5 hunks)
  • ee/packages/federation-matrix/tests/end-to-end/dms.spec.ts (6 hunks)
  • packages/core-services/src/types/IRoomService.ts (2 hunks)

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.

@sampaiodiego sampaiodiego force-pushed the test-federation-empty-dm-state branch from 75fc3d0 to 6674a96 Compare December 16, 2025 22:05
@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch from 484e78d to b96badd Compare December 16, 2025 22:08
@ggazzo ggazzo force-pushed the test-federation-empty-dm-state branch from 284f7bb to eb67e4b Compare December 17, 2025 14:25
@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch from b96badd to f91381d Compare December 17, 2025 16:40
@ggazzo ggazzo force-pushed the test-federation-empty-dm-state branch from 83299a8 to 9b8c873 Compare December 17, 2025 19:42
@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch 2 times, most recently from cb1c027 to a30039d Compare December 17, 2025 20:56
@github-actions
Copy link
Contributor

github-actions bot commented Dec 17, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +12MiB
rocketchat 358MiB 347MiB +12MiB
omnichannel-transcript-service 132MiB 132MiB +3.7KiB
queue-worker-service 132MiB 132MiB +105B
ddp-streamer-service 126MiB 126MiB -618B
account-service 113MiB 113MiB +69B
authorization-service 111MiB 111MiB +460B
stream-hub-service 110MiB 110MiB +407B
presence-service 110MiB 110MiB +249B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 19:04", "12/18 19:27 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 24 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37840
  • Baseline: develop
  • Timestamp: 2025-12-18 19:27:30 UTC
  • Historical data points: 24

Updated: Thu, 18 Dec 2025 19:27:30 GMT

@sampaiodiego sampaiodiego force-pushed the test-federation-empty-dm-state branch from 56a63e2 to baefb64 Compare December 17, 2025 21:44
@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch 2 times, most recently from e61ca81 to 22c643a Compare December 18, 2025 13:48
@sampaiodiego
Copy link
Member Author

/bark

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 18, 2025

AU AU

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

❌ Patch coverage is 28.57143% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.72%. Comparing base (65214b6) to head (a299092).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37840      +/-   ##
===========================================
- Coverage    67.75%   67.72%   -0.03%     
===========================================
  Files         3463     3464       +1     
  Lines       113702   113730      +28     
  Branches     20901    20908       +7     
===========================================
- Hits         77034    77026       -8     
- Misses       34501    34527      +26     
- Partials      2167     2177      +10     
Flag Coverage Δ
e2e 57.18% <ø> (-0.03%) ⬇️
e2e-api 43.97% <28.57%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@sampaiodiego sampaiodiego marked this pull request as ready for review December 18, 2025 18:44
@sampaiodiego sampaiodiego requested review from a team as code owners December 18, 2025 18:44
@sampaiodiego sampaiodiego force-pushed the test-federation-empty-dm-state branch from baefb64 to 3692b7a Compare December 18, 2025 18:55
@sampaiodiego sampaiodiego requested a review from a team as a code owner December 18, 2025 18:55
@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch from 75c2b9b to a299092 Compare December 18, 2025 18:56
@ggazzo ggazzo added this to the 7.14.0 milestone Dec 18, 2025
@ggazzo ggazzo added the stat: QA assured Means it has been tested and approved by a company insider label Dec 18, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 18, 2025
Base automatically changed from test-federation-empty-dm-state to develop December 18, 2025 19:58
@kodiakhq kodiakhq bot removed the stat: ready to merge PR tested and approved waiting for merge label Dec 18, 2025
@kodiakhq
Copy link
Contributor

kodiakhq bot commented Dec 18, 2025

This PR currently has a merge conflict. Please resolve this and then re-add the ['stat: ready to merge', 'automerge'] label.

@sampaiodiego sampaiodiego force-pushed the fix-federation-group-dm-name-after-join branch from a299092 to aa6dbc8 Compare December 18, 2025 20:12
@ggazzo ggazzo merged commit 5106fcd into develop Dec 18, 2025
6 of 9 checks passed
@ggazzo ggazzo deleted the fix-federation-group-dm-name-after-join branch December 18, 2025 20:14
gaolin1 pushed a commit to gaolin1/medsense.webchat that referenced this pull request Jan 6, 2026
@dougfabris dougfabris modified the milestones: 7.14.0, 8.0.0 Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants