aboutsummaryrefslogtreecommitdiff
path: root/matrix
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-03-26 16:59:38 +0200
committerTulir Asokan <tulir@maunium.net>2019-03-26 16:59:38 +0200
commitded4767729cedb8457b343b584d40302d518eba2 (patch)
tree521a378f3da0af1ddc4cf956cb68b47b3aaabdc6 /matrix
parent8aa134b8b23cf945f5a18e21e5fa4855e188d3c0 (diff)
Fix normal events being handled as state events
Diffstat (limited to 'matrix')
-rw-r--r--matrix/sync.go12
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