aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roomserver/internal/input/input_events.go4
-rw-r--r--roomserver/internal/input/input_latest_events.go19
-rw-r--r--roomserver/storage/tables/events_table_test.go1
-rw-r--r--roomserver/types/types.go4
4 files changed, 12 insertions, 16 deletions
diff --git a/roomserver/internal/input/input_events.go b/roomserver/internal/input/input_events.go
index 3ab9ba4f..d437d776 100644
--- a/roomserver/internal/input/input_events.go
+++ b/roomserver/internal/input/input_events.go
@@ -535,8 +535,6 @@ func (r *Inputer) calculateAndSetState(
roomState := state.NewStateResolution(updater, roomInfo)
if input.HasState {
- stateAtEvent.Overwrite = true
-
// We've been told what the state at the event is so we don't need to calculate it.
// Check that those state events are in the database and store the state.
var entries []types.StateEntry
@@ -549,8 +547,6 @@ func (r *Inputer) calculateAndSetState(
return fmt.Errorf("updater.AddState: %w", err)
}
} else {
- stateAtEvent.Overwrite = false
-
// We haven't been told what the state at the event is so we need to calculate it from the prev_events
if stateAtEvent.BeforeStateSnapshotNID, err = roomState.CalculateAndStoreStateBeforeEvent(ctx, event, isRejected); err != nil {
return fmt.Errorf("roomState.CalculateAndStoreStateBeforeEvent: %w", err)
diff --git a/roomserver/internal/input/input_latest_events.go b/roomserver/internal/input/input_latest_events.go
index e4c138d5..4e5b7342 100644
--- a/roomserver/internal/input/input_latest_events.go
+++ b/roomserver/internal/input/input_latest_events.go
@@ -27,6 +27,7 @@ import (
"github.com/matrix-org/dendrite/roomserver/types"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
+ "github.com/sirupsen/logrus"
)
// updateLatestEvents updates the list of latest events for this room in the database and writes the
@@ -258,13 +259,6 @@ func (u *latestEventsUpdater) latestState() error {
return fmt.Errorf("roomState.CalculateAndStoreStateAfterEvents: %w", err)
}
- // If we are overwriting the state then we should make sure that we
- // don't send anything out over federation again, it will very likely
- // be a repeat.
- if u.stateAtEvent.Overwrite {
- u.sendAsServer = ""
- }
-
// Now that we have a new state snapshot based on the latest events,
// we can compare that new snapshot to the previous one and see what
// has changed. This gives us one list of removed state events and
@@ -277,6 +271,17 @@ func (u *latestEventsUpdater) latestState() error {
return fmt.Errorf("roomState.DifferenceBetweenStateSnapshots: %w", err)
}
+ if removed := len(u.removed) - len(u.added); removed > 0 {
+ logrus.WithFields(logrus.Fields{
+ "event_id": u.event.EventID(),
+ "room_id": u.event.RoomID(),
+ "old_state_nid": u.oldStateNID,
+ "new_state_nid": u.newStateNID,
+ "old_latest": u.oldLatest,
+ "new_latest": u.latest,
+ }).Errorf("Unexpected state deletion (removing %d events)", removed)
+ }
+
// Also work out the state before the event removes and the event
// adds.
u.stateBeforeEventRemoves, u.stateBeforeEventAdds, err = roomState.DifferenceBetweeenStateSnapshots(
diff --git a/roomserver/storage/tables/events_table_test.go b/roomserver/storage/tables/events_table_test.go
index 6f72a59b..74502a31 100644
--- a/roomserver/storage/tables/events_table_test.go
+++ b/roomserver/storage/tables/events_table_test.go
@@ -85,7 +85,6 @@ func Test_EventsTable(t *testing.T) {
assert.NoError(t, err)
}
stateAtEvent := types.StateAtEvent{
- Overwrite: false,
BeforeStateSnapshotNID: types.StateSnapshotNID(stateSnapshot),
IsRejected: false,
StateEntry: types.StateEntry{
diff --git a/roomserver/types/types.go b/roomserver/types/types.go
index 62695aae..cf12a3c1 100644
--- a/roomserver/types/types.go
+++ b/roomserver/types/types.go
@@ -173,10 +173,6 @@ func DeduplicateStateEntries(a []StateEntry) []StateEntry {
// StateAtEvent is the state before and after a matrix event.
type StateAtEvent struct {
- // Should this state overwrite the latest events and memberships of the room?
- // This might be necessary when rejoining a federated room after a period of
- // absence, as our state and latest events will be out of date.
- Overwrite bool
// The state before the event.
BeforeStateSnapshotNID StateSnapshotNID
// True if this StateEntry is rejected. State resolution should then treat this