From ded4767729cedb8457b343b584d40302d518eba2 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 26 Mar 2019 16:59:38 +0200 Subject: [PATCH] Fix normal events being handled as state events --- matrix/sync.go | 12 +++++++++--- 1 file 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