Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #175 +/- ##
=======================================
Coverage 80.42% 80.42%
=======================================
Files 58 58
Lines 4516 4516
=======================================
Hits 3632 3632
Misses 884 884 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
packages/homeserver/src/controllers/federation/transactions.controller.ts
Outdated
Show resolved
Hide resolved
|
Caution Review failedThe pull request is closed. WalkthroughAdds GET /_matrix/federation/v1/event/:eventId and related DTOs; integrates ConfigService into federation transactions controller; refactors route registration to chained app.put(...).get(...); GET returns event PDUs with embedded origin and origin_server_ts or a standardized error. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Federation peer
participant HS as Homeserver App
participant TC as TransactionsController
participant ES as EventService
participant CS as ConfigService
rect rgb(240,248,255)
note over C,HS: GET /_matrix/federation/v1/event/:eventId
C->>HS: HTTP GET /event/:eventId
HS->>TC: invoke GET handler (params validated)
TC->>ES: getEventById(eventId)
ES-->>TC: event | null
alt event found
TC->>CS: read serverName
CS-->>TC: origin (serverName)
TC-->>C: 200 { origin_server_ts, origin, pdus:[ event(with origin) ] }
else not found
TC-->>C: 404 { errcode: M_NOT_FOUND, error }
end
end
sequenceDiagram
autonumber
participant FP as Federation peer
participant HS as Homeserver App
participant TC as TransactionsController
rect rgb(245,255,245)
note over FP,HS: PUT /_matrix/federation/v1/send/:txnId
FP->>HS: HTTP PUT { pdus, edus }
HS->>TC: invoke PUT handler
TC-->>FP: 200 { pdus:[], edus:[] } or 400 on invalid
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (1)
packages/homeserver/src/controllers/federation/transactions.controller.ts (1)
17-41: Prior feedback addressed: routes are properly chained.The
.put().get()chaining resolves the earlier review note.
🧹 Nitpick comments (4)
packages/homeserver/src/dtos/federation/transactions.dto.ts (4)
32-34: Validate Matrix event ID format.Early-validate
:eventIdto reduce unnecessary lookups and 404s.export const GetEventParamsDto = t.Object({ - eventId: t.String({ description: 'Event ID' }), + eventId: t.String({ + description: 'Event ID', + // Matrix event IDs look like `$something:server` + pattern: '^\\$.+:.+$', + }), });
36-42: Constrain response to exactly one PDU.Contract says “single PDU”; enforce it in the schema.
export const GetEventResponseDto = t.Object({ origin_server_ts: t.Number({ description: 'Origin server timestamp' }), origin: t.String({ description: 'Origin server' }), pdus: t.Array(EventBaseDto, { - description: 'An array containing a single PDU', + description: 'An array containing a single PDU', + minItems: 1, + maxItems: 1, }), });
1-2: Optional: Reuse TimestampDto for consistency.Align the top-level
origin_server_tswith the scalar used in events.-import { EventBaseDto } from '../common/event.dto'; +import { EventBaseDto, TimestampDto } from '../common/event.dto';- origin_server_ts: t.Number({ description: 'Origin server timestamp' }), + origin_server_ts: TimestampDto,
44-47: Unify error DTOs across federation endpoints.Consider a shared
FederationErrorResponseDtoto avoid divergence withErrorResponseDtoand keep err shapes consistent.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/homeserver/src/controllers/federation/transactions.controller.ts(1 hunks)packages/homeserver/src/dtos/federation/transactions.dto.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/homeserver/src/dtos/federation/transactions.dto.ts (1)
packages/homeserver/src/dtos/common/event.dto.ts (1)
EventBaseDto(19-36)
packages/homeserver/src/controllers/federation/transactions.controller.ts (3)
packages/federation-sdk/src/services/config.service.ts (1)
ConfigService(74-147)packages/homeserver/src/dtos/federation/transactions.dto.ts (5)
SendTransactionBodyDto(8-21)SendTransactionResponseDto(23-30)GetEventParamsDto(32-34)GetEventResponseDto(36-42)GetEventErrorResponseDto(44-47)packages/homeserver/src/dtos/common/error.dto.ts (1)
ErrorResponseDto(3-6)
🔇 Additional comments (2)
packages/homeserver/src/dtos/federation/transactions.dto.ts (1)
52-53: Type exports look good.packages/homeserver/src/controllers/federation/transactions.controller.ts (1)
62-67: Align declared 401/403/500 responses with behavior.Either add auth/permission checks that set these statuses or remove them from the schema to avoid misleading OpenAPI.
Option A: keep and implement (preferred).
Option B (schema-only):response: { - 401: GetEventErrorResponseDto, - 403: GetEventErrorResponseDto, - 500: GetEventErrorResponseDto, },
packages/homeserver/src/controllers/federation/transactions.controller.ts
Show resolved
Hide resolved
packages/homeserver/src/controllers/federation/transactions.controller.ts
Show resolved
Hide resolved
packages/homeserver/src/controllers/federation/transactions.controller.ts
Show resolved
Hide resolved
packages/homeserver/src/controllers/federation/transactions.controller.ts
Show resolved
Hide resolved
ce3f411 to
a47b32a
Compare
Summary by CodeRabbit
New Features
Improvements