diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2023-07-07 22:00:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-07 22:00:10 +0200 |
commit | 74a5ab6c2465b6fbd736ea2e4beb149fa06fc850 (patch) | |
tree | 60e5c35610a2b48bfb1a84cf7760669d761c2251 /syncapi | |
parent | eb9e90379d9f19b1b4192248cbf4931874324857 (diff) |
Fix issues reported by Sentry (#3143)
This should fix a few issues reported by Sentry
Diffstat (limited to 'syncapi')
-rw-r--r-- | syncapi/streams/stream_pdu.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/syncapi/streams/stream_pdu.go b/syncapi/streams/stream_pdu.go index 1a4e5351..3f688880 100644 --- a/syncapi/streams/stream_pdu.go +++ b/syncapi/streams/stream_pdu.go @@ -371,19 +371,26 @@ func (p *PDUStreamProvider) addRoomDeltaToResponse( gomatrixserverlib.TopologicalOrderByAuthEvents, ) delta.StateEvents = make([]*rstypes.HeaderedEvent, len(sEvents)) + var skipped int for i := range sEvents { ev := sEvents[i] - delta.StateEvents[i] = ev.(*rstypes.HeaderedEvent) + he, ok := ev.(*rstypes.HeaderedEvent) + if !ok { + skipped++ + continue + } + delta.StateEvents[i-skipped] = he // update the powerlevel event for state events if ev.Version() == gomatrixserverlib.RoomVersionPseudoIDs && ev.Type() == spec.MRoomPowerLevels && ev.StateKeyEquals("") { var newEvent gomatrixserverlib.PDU - newEvent, err = p.updatePowerLevelEvent(ctx, ev.(*rstypes.HeaderedEvent)) + newEvent, err = p.updatePowerLevelEvent(ctx, he) if err != nil { return r.From, err } - delta.StateEvents[i] = &rstypes.HeaderedEvent{PDU: newEvent} + delta.StateEvents[i-skipped] = &rstypes.HeaderedEvent{PDU: newEvent} } } + delta.StateEvents = delta.StateEvents[:len(sEvents)-skipped] if len(delta.StateEvents) > 0 { if last := delta.StateEvents[len(delta.StateEvents)-1]; last != nil { |