Skip to content

Conversation

@rodrigok
Copy link
Member

@rodrigok rodrigok commented Oct 9, 2025

https://rocketchat.atlassian.net/browse/FDR-195

Relates to RocketChat/Rocket.Chat#37191

Summary by CodeRabbit

  • New Features

    • Support for encrypted room messages throughout the app: processing, authorization checks, timeline handling.
    • Emits a new encrypted-message event with metadata and preserved relation info (edits, reactions, threads).
  • Refactor

    • Unified relation handling under a single structure shared by message and encrypted content.
    • Reorganized base content schemas to separate timeline relation fields from message-specific fields.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds support for m.room.encrypted across federation SDK and room schemas: new encrypted event emission in staging area, inclusion in auth-event discovery, expanded HomeserverEventSignatures with a localized RelatesTo type, and new timeline/encrypted content schemas.

Changes

Cohort / File(s) Summary
Federation SDK: Typings
packages/federation-sdk/src/index.ts
Introduced internal RelatesTo type; added homeserver.matrix.encrypted signature; changed homeserver.matrix.message content to use m.relates_to?: RelatesTo.
Federation SDK: Event auth discovery
packages/federation-sdk/src/repositories/event.repository.ts
Added m.room.encrypted to auth-event discovery switch so encrypted events are included in auth-related queries.
Federation SDK: Staging and emissions
packages/federation-sdk/src/services/staging-area.service.ts
Added handling for m.room.encrypted in notification/staging flow; emits homeserver.matrix.encrypted with event metadata and content (including m.relates_to).
Room Schemas: Timeline and encrypted
packages/room/src/types/v3-11.ts
Added BaseTimelineContentSchema for relation fields; updated BaseMessageContentSchema to extend it; added EncryptedContentSchema; added EventPduTypeRoomEncrypted; included m.room.encrypted in PduTimelineSchema and isTimelineEventType.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor HS as Homeserver
  participant SA as StagingAreaService
  participant ER as EventRepository
  participant EB as EventBus

  rect #F2F8FF
  note over HS: Incoming room event
  HS->>SA: m.room.message / m.room.encrypted
  end

  alt plaintext message
    SA->>ER: fetch auth-related events (message)
    ER-->>SA: auth events
    SA-->>EB: emit homeserver.matrix.message (content, m.relates_to)
  else encrypted message
    SA->>ER: fetch auth-related events (encrypted)
    ER-->>SA: auth events (includes encrypted)
    SA-->>EB: emit homeserver.matrix.encrypted (content, m.relates_to)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I hop through packets, soft and spry,
Encryptions hum beneath the sky.
Relations tidy, threads aligned,
Encrypted whispers now defined.
A rabbit cheers — no logs that cry! 🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The PR includes refactoring of existing message relation typing in HomeserverEventSignatures and room timeline schemas—changes that extend or reorganize the m.room.message and timeline content structures beyond what is required to support encrypted messages. Please split out the unrelated refactoring of message relation types and timeline schemas into a separate PR, keeping this one focused solely on implementing support for m.room.encrypted events.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title “feat: add support to encrypted messages” clearly summarizes the primary change of enabling handling for encrypted message events and follows a concise, conventional format that accurately reflects the PR’s main purpose.
Linked Issues Check ✅ Passed The changes comprehensively address the FDR-195 objective by adding support for the m.room.encrypted event type across event signatures, authorization queries, staging services, and type schemas, thereby resolving the “Unsupported event type” error.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

📜 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 c78ea92 and 06861cd.

📒 Files selected for processing (1)
  • packages/room/src/types/v3-11.ts (6 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.

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.31%. Comparing base (ce0db0f) to head (06861cd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ederation-sdk/src/repositories/event.repository.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
- Coverage   62.34%   60.31%   -2.04%     
==========================================
  Files          67       67              
  Lines        6393     6672     +279     
==========================================
+ Hits         3986     4024      +38     
- Misses       2407     2648     +241     

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 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 ce0db0f and c78ea92.

📒 Files selected for processing (4)
  • packages/federation-sdk/src/index.ts (3 hunks)
  • packages/federation-sdk/src/repositories/event.repository.ts (1 hunks)
  • packages/federation-sdk/src/services/staging-area.service.ts (1 hunks)
  • packages/room/src/types/v3-11.ts (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/federation-sdk/src/services/staging-area.service.ts (4)
packages/room/src/manager/event-wrapper.ts (2)
  • event (128-137)
  • roomId (100-102)
packages/room/src/manager/v3.ts (1)
  • eventId (17-29)
packages/federation-sdk/src/index.ts (1)
  • EventID (27-27)
packages/room/src/types/_common.ts (1)
  • EventID (8-8)
packages/federation-sdk/src/index.ts (1)
packages/room/src/types/_common.ts (2)
  • EventID (8-8)
  • PduForType (26-26)

@ggazzo ggazzo merged commit 8d451e3 into main Oct 9, 2025
2 of 3 checks passed
@ggazzo ggazzo deleted the feat/m.room.encrypted branch October 9, 2025 20:49
@coderabbitai coderabbitai bot mentioned this pull request Nov 3, 2025
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.

4 participants