Properly ignore presence in sync filter

This commit is contained in:
Tulir Asokan 2020-03-03 22:53:42 +02:00
parent 1eab5526e3
commit 5db5cd550d

View File

@ -186,7 +186,8 @@ func (s *GomuksSyncer) OnEventType(eventType mautrix.EventType, callback EventHa
func (s *GomuksSyncer) notifyListeners(source EventSource, event *mautrix.Event) { func (s *GomuksSyncer) notifyListeners(source EventSource, event *mautrix.Event) {
if (event.Type.IsState() && source&EventSourceState == 0 && event.StateKey == nil) || if (event.Type.IsState() && source&EventSourceState == 0 && event.StateKey == nil) ||
(event.Type.IsAccountData() && source&EventSourceAccountData == 0) || (event.Type.IsAccountData() && source&EventSourceAccountData == 0) ||
(event.Type.IsEphemeral() && source&EventSourceEphemeral == 0) { (event.Type.IsEphemeral() && event.Type != mautrix.EphemeralEventPresence && source&EventSourceEphemeral == 0) ||
(event.Type == mautrix.EphemeralEventPresence && source&EventSourcePresence == 0) {
evtJson, _ := json.Marshal(event) evtJson, _ := json.Marshal(event)
debug.Printf("Event of type %s received from mismatching source %s: %s", event.Type.String(), source.String(), string(evtJson)) debug.Printf("Event of type %s received from mismatching source %s: %s", event.Type.String(), source.String(), string(evtJson))
return return
@ -253,7 +254,7 @@ func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage {
Types: []string{"m.push_rules", "m.direct", "net.maunium.gomuks.preferences"}, Types: []string{"m.push_rules", "m.direct", "net.maunium.gomuks.preferences"},
}, },
Presence: mautrix.FilterPart{ Presence: mautrix.FilterPart{
Types: []string{}, NotTypes: []string{"*"},
}, },
} }
rawFilter, _ := json.Marshal(&filter) rawFilter, _ := json.Marshal(&filter)