aboutsummaryrefslogtreecommitdiff
path: root/roomserver/state
diff options
context:
space:
mode:
authorKegsay <kegan@matrix.org>2020-09-16 13:00:52 +0100
committerGitHub <noreply@github.com>2020-09-16 13:00:52 +0100
commit18231f25b437d2f03b3be1e0536fc46d45c8691f (patch)
tree5a3ef66c25268df8214be69f0c9e1f5f925da14f /roomserver/state
parentba6c7c4a5c4166b7085343886ab69ef331238ff4 (diff)
Implement rejected events (#1426)
* WIP Event rejection * Still send back errors for rejected events Instead, discard them at the federationapi /send layer rather than re-implementing checks at the clientapi/PerformJoin layer. * Implement rejected events Critically, rejected events CAN cause state resolution to happen as it can merge forks in the DAG. This is fine, _provided_ we do not add the rejected event when performing state resolution, which is what this PR does. It also fixes the error handling when NotAllowed happens, as we were checking too early and needlessly handling NotAllowed in more than one place. * Update test to match reality * Modify InputRoomEvents to no longer return an error Errors do not serialise across HTTP boundaries in polylith mode, so instead set fields on the InputRoomEventsResponse. Add `Err()` function to make the API shape basically the same. * Remove redundant returns; linting * Update blacklist
Diffstat (limited to 'roomserver/state')
-rw-r--r--roomserver/state/state.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/roomserver/state/state.go b/roomserver/state/state.go
index 37e6807a..9ee6f40d 100644
--- a/roomserver/state/state.go
+++ b/roomserver/state/state.go
@@ -159,7 +159,7 @@ func (v StateResolution) LoadCombinedStateAfterEvents(
}
fullState = append(fullState, entries...)
}
- if prevState.IsStateEvent() {
+ if prevState.IsStateEvent() && !prevState.IsRejected {
// If the prev event was a state event then add an entry for the event itself
// so that we get the state after the event rather than the state before.
fullState = append(fullState, prevState.StateEntry)
@@ -523,6 +523,7 @@ func init() {
func (v StateResolution) CalculateAndStoreStateBeforeEvent(
ctx context.Context,
event gomatrixserverlib.Event,
+ isRejected bool,
) (types.StateSnapshotNID, error) {
// Load the state at the prev events.
prevEventRefs := event.PrevEvents()
@@ -561,7 +562,7 @@ func (v StateResolution) CalculateAndStoreStateAfterEvents(
if len(prevStates) == 1 {
prevState := prevStates[0]
- if prevState.EventStateKeyNID == 0 {
+ if prevState.EventStateKeyNID == 0 || prevState.IsRejected {
// 3) None of the previous events were state events and they all
// have the same state, so this event has exactly the same state
// as the previous events.