-
Notifications
You must be signed in to change notification settings - Fork 20
chore: add support for events "m.room.topic" #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds m.room.topic as a recognized auth event type and updates event-to-query mappings in the repository. Adjusts switch-case logic for several Matrix event types, including create, redaction, name, message, power_levels, and topic. Service layer now includes m.room.topic in getAuthEventIds. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Caller
participant S as EventService
participant R as EventRepository
C->>S: getAuthEventIds(event)
S->>S: Determine auth types (includes "m.room.topic")
S->>R: findAuthEvents(event.type)
alt type == m.room.create
R->>R: Use baseQueries.create
else type == m.room.redaction
R->>R: Use create + powerLevels
else type == m.room.power_levels or m.room.topic
R->>R: Use create + powerLevels + membership
else type == m.room.name or m.room.message
R->>R: Use default/collapsed handling
end
R-->>S: Auth events
S-->>C: Auth event IDs
note over S,R: New handling path for "m.room.topic"
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
==========================================
+ Coverage 62.12% 62.39% +0.26%
==========================================
Files 67 67
Lines 6390 6363 -27
==========================================
Hits 3970 3970
+ Misses 2420 2393 -27 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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.
📒 Files selected for processing (2)
packages/federation-sdk/src/repositories/event.repository.ts(1 hunks)packages/federation-sdk/src/services/event.service.ts(1 hunks)
🔇 Additional comments (3)
packages/federation-sdk/src/services/event.service.ts (1)
559-571: LGTM! Service layer now recognizesm.room.topic.The addition of
m.room.topicto the allowed auth event types array ensures consistency with the repository changes and prevents the unrecognized event type warning at lines 574-576.This change correctly completes the support for
m.room.topicevents across both the repository and service layers, addressing the issue described in FDR-200.packages/federation-sdk/src/repositories/event.repository.ts (2)
58-64: Confirm intent and add tests form.room.createandm.room.redactionauth events
Ensure the updated auth event mappings align with the Matrix specification and add dedicated tests forfindAuthEventscovering these event types.
71-71: LGTM – m.room.topic support added correctlyVerified auth_events (m.room.create, m.room.power_levels, m.room.member) align with Matrix spec.
| switch (eventType) { | ||
| case 'm.room.name': | ||
| queries = [ | ||
| baseQueries.create, | ||
| baseQueries.powerLevels, | ||
| baseQueries.membership, | ||
| ]; | ||
| case 'm.room.create': | ||
| queries = [baseQueries.create]; | ||
| break; | ||
|
|
||
| case 'm.room.message': | ||
| queries = [ | ||
| baseQueries.create, | ||
| baseQueries.powerLevels, | ||
| baseQueries.membership, | ||
| ]; | ||
| case 'm.room.redaction': | ||
| queries = [baseQueries.create, baseQueries.powerLevels]; | ||
| break; | ||
|
|
||
| case 'm.reaction': | ||
| queries = [ | ||
| baseQueries.create, | ||
| baseQueries.powerLevels, | ||
| baseQueries.membership, | ||
| ]; | ||
| break; | ||
|
|
||
| case 'm.room.name': | ||
| case 'm.room.message': | ||
| case 'm.room.member': | ||
| queries = [ | ||
| baseQueries.create, | ||
| baseQueries.powerLevels, | ||
| baseQueries.membership, | ||
| ]; | ||
| break; | ||
|
|
||
| case 'm.room.create': | ||
| queries = [baseQueries.create]; | ||
| break; | ||
|
|
||
| case 'm.room.power_levels': | ||
| case 'm.room.topic': | ||
| queries = [ | ||
| baseQueries.create, | ||
| baseQueries.powerLevels, | ||
| baseQueries.membership, | ||
| ]; | ||
| break; | ||
|
|
||
| case 'm.room.redaction': | ||
| queries = [baseQueries.create, baseQueries.powerLevels]; | ||
| break; | ||
|
|
||
| default: | ||
| throw new Error(`Unsupported event type: ${eventType}`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add test coverage for the new m.room.topic support.
The Codecov report indicates 0% patch coverage with 7 lines missing coverage in this file. Since this change adds support for a new event type and modifies auth event behavior for existing types, comprehensive test coverage is essential to prevent regressions.
Consider adding tests that:
- Verify
m.room.topicreturns the correct auth events (create, powerLevels, membership) - Validate the refactored auth event queries for
m.room.createandm.room.redaction - Ensure the default case throws an error for truly unsupported event types
Would you like me to generate test cases for the findAuthEvents method covering the new m.room.topic support?
🤖 Prompt for AI Agents
In packages/federation-sdk/src/repositories/event.repository.ts around lines 57
to 81, tests are missing for the newly-added m.room.topic branch and modified
auth-event behavior; add unit tests for findAuthEvents that (1) assert
m.room.topic returns [create, powerLevels, membership] auth event queries, (2)
verify m.room.create and m.room.redaction return their expected query sets
(create only and create+powerLevels respectively), and (3) confirm the default
branch throws for unsupported event types; mock any dependencies or baseQueries
inputs and assert that the method selects the correct query array for each
eventType.
https://rocketchat.atlassian.net/browse/FDR-200
Summary by CodeRabbit
New Features
Bug Fixes