mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Resolve state after event against current room state when determining latest state changes (#1479)
* Resolve state after event against current room state when determining latest state changes * Update sytest-whitelist * Update sytest-whitelist, blacklist
This commit is contained in:
parent
4e6b7f726d
commit
2e71d2708f
4 changed files with 31 additions and 11 deletions
|
@ -215,10 +215,27 @@ func (u *latestEventsUpdater) latestState() error {
|
|||
var err error
|
||||
roomState := state.NewStateResolution(u.api.DB, *u.roomInfo)
|
||||
|
||||
// Get a list of the current latest events.
|
||||
latestStateAtEvents := make([]types.StateAtEvent, len(u.latest))
|
||||
// Get a list of the current room state events if available.
|
||||
var currentState []types.StateEntry
|
||||
if u.roomInfo.StateSnapshotNID != 0 {
|
||||
currentState, _ = roomState.LoadStateAtSnapshot(u.ctx, u.roomInfo.StateSnapshotNID)
|
||||
}
|
||||
|
||||
// Get a list of the current latest events. This will include both
|
||||
// the current room state and the latest events after the input event.
|
||||
// The idea is that we will perform state resolution on this set and
|
||||
// any conflicting events will be resolved properly.
|
||||
latestStateAtEvents := make([]types.StateAtEvent, len(u.latest)+len(currentState))
|
||||
offset := 0
|
||||
for i := range currentState {
|
||||
latestStateAtEvents[i] = types.StateAtEvent{
|
||||
BeforeStateSnapshotNID: u.roomInfo.StateSnapshotNID,
|
||||
StateEntry: currentState[i],
|
||||
}
|
||||
offset++
|
||||
}
|
||||
for i := range u.latest {
|
||||
latestStateAtEvents[i] = u.latest[i].StateAtEvent
|
||||
latestStateAtEvents[offset+i] = u.latest[i].StateAtEvent
|
||||
}
|
||||
|
||||
// Takes the NIDs of the latest events and creates a state snapshot
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue