-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Refactor event building into EventBuilder #4481
Conversation
b0b1161
to
9fb9205
Compare
Codecov Report
@@ Coverage Diff @@
## develop #4481 +/- ##
===========================================
+ Coverage 67.87% 74.76% +6.89%
===========================================
Files 336 336
Lines 34163 34198 +35
Branches 5556 5564 +8
===========================================
+ Hits 23188 25568 +2380
+ Misses 9362 7054 -2308
+ Partials 1613 1576 -37 |
This is so that everything is done in one place, making it easier to change the event format based on room version
`.user_id` is proxed to `.sender` in FrozenEvent, so this has no functional change
6b70f5e
to
aee39f7
Compare
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.
generally seems plausible. a few questions.
Deferred[FrozenEvent] | ||
""" | ||
|
||
state_ids = yield self._state.get_current_state_ids( |
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.
Slightly concerned that we used to do context.get_prev_state_ids
, which might return something different to this?
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.
In practice, they're exactly the same, compute_event_context
just resolves the state across the prev_events
to get prev_state_ids
. From a protocol perspective, auth_events
should be based on the state at the event.
We could make compute_event_context
work with an EventBuilder
, but I was slightly shying away from doing so in the interests of not changing too much. We could probably do so though
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.
lgtm I think...
This is so that everything is done in one place, making it easier to change the event format based on room version.
The crux of what's happening here is that the
EventBuilder
is now meant to be independent of the format version, allowing the rest of the code to build up events without worrying about different versions. This is done by making it anattr
class with well defined fields that are of interest when building an event (mainlytype
/state_key
/content
/etc), and only adding the rest of the fields when we finally build the event (which handles things like adding prev events, signing and hashing it, using the right format etc)Hopefully the commits are relatively stand alone.