Skip to content

Commit

Permalink
Exclude old state events from sync when consumed from roomserver (#1548)
Browse files Browse the repository at this point in the history
* Exclude old room events from sync when consumed from roomserver

* Fix comment

* Experimental hack
  • Loading branch information
neilalexander authored Oct 22, 2020
1 parent 3afc623 commit f32320a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions syncapi/consumers/roomserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,20 @@ func (s *OutputRoomEventConsumer) onOldRoomEvent(
) error {
ev := msg.Event

// TODO: The state key check when excluding from sync is designed
// to stop us from lying to clients with old state, whilst still
// allowing normal timeline events through. This is an absolute
// hack but until we have some better strategy for dealing with
// old events in the sync API, this should at least prevent us
// from confusing clients into thinking they've joined/left rooms.
pduPos, err := s.db.WriteEvent(
ctx,
&ev,
[]gomatrixserverlib.HeaderedEvent{},
[]string{}, // adds no state
[]string{}, // removes no state
nil, // no transaction
false, // not excluded from sync
[]string{}, // adds no state
[]string{}, // removes no state
nil, // no transaction
ev.StateKey() != nil, // exclude from sync?
)
if err != nil {
// panic rather than continue with an inconsistent database
Expand Down

0 comments on commit f32320a

Please sign in to comment.