diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-03-26 16:59:38 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-03-26 16:59:38 +0200 |
commit | ded4767729cedb8457b343b584d40302d518eba2 (patch) | |
tree | 521a378f3da0af1ddc4cf956cb68b47b3aaabdc6 | |
parent | 8aa134b8b23cf945f5a18e21e5fa4855e188d3c0 (diff) |
Fix normal events being handled as state events
-rw-r--r-- | matrix/sync.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/matrix/sync.go b/matrix/sync.go index 837a340..750db3f 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -120,9 +120,9 @@ func (s *GomuksSyncer) processSyncEvents(room *rooms.Room, events []*mautrix.Eve func (s *GomuksSyncer) processSyncEvent(room *rooms.Room, event *mautrix.Event, source EventSource) { if room != nil { event.RoomID = room.ID - } - if event.Type.Class == mautrix.StateEventType { - room.UpdateState(event) + if source&EventSourceState != 0 { + room.UpdateState(event) + } } s.notifyListeners(source, event) } @@ -138,6 +138,12 @@ func (s *GomuksSyncer) OnEventType(eventType mautrix.EventType, callback EventHa } func (s *GomuksSyncer) notifyListeners(source EventSource, event *mautrix.Event) { + if event.Type.IsState() && source&EventSourceState == 0 || + event.Type.IsAccountData() && source&EventSourceAccountData == 0 || + event.Type.IsEphemeral() && source&EventSourceEphemeral == 0 { + debug.Printf("Event of type %s received from mismatching source %s: %v.", event.Type, source, event) + return + } listeners, exists := s.listeners[event.Type] if !exists { return |