Fix normal events being handled as state events

This commit is contained in:
Tulir Asokan 2019-03-26 16:59:38 +02:00
parent 8aa134b8b2
commit ded4767729

View File

@ -120,10 +120,10 @@ 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 {
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