aboutsummaryrefslogtreecommitdiff
path: root/matrix/sync.go
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-09-05 10:55:48 +0300
committerTulir Asokan <tulir@maunium.net>2018-09-05 10:55:48 +0300
commitcfb2cc057c32330be0ca0a68cfbd245cb2b8e31b (patch)
treef0d02d40d41091fd052582fe1fe701c80decf0d7 /matrix/sync.go
parent68db26bcace31297471641fe95f8882e301f5699 (diff)
Update to latest gomatrix. Things are broken
Diffstat (limited to 'matrix/sync.go')
-rw-r--r--matrix/sync.go17
1 files changed, 4 insertions, 13 deletions
diff --git a/matrix/sync.go b/matrix/sync.go
index 2037fcd..6d5def7 100644
--- a/matrix/sync.go
+++ b/matrix/sync.go
@@ -51,7 +51,7 @@ type EventHandler func(source EventSource, event *gomatrix.Event)
// pattern to notify callers about incoming events. See GomuksSyncer.OnEventType for more information.
type GomuksSyncer struct {
Session SyncerSession
- listeners map[string][]EventHandler // event type to listeners array
+ listeners map[gomatrix.EventType][]EventHandler // event type to listeners array
FirstSyncDone bool
InitDoneCallback func()
}
@@ -60,7 +60,7 @@ type GomuksSyncer struct {
func NewGomuksSyncer(session SyncerSession) *GomuksSyncer {
return &GomuksSyncer{
Session: session,
- listeners: make(map[string][]EventHandler),
+ listeners: make(map[gomatrix.EventType][]EventHandler),
FirstSyncDone: false,
}
}
@@ -114,20 +114,11 @@ func (s *GomuksSyncer) processSyncEvents(room *rooms.Room, events []*gomatrix.Ev
}
}
-func isState(event *gomatrix.Event) bool {
- switch event.Type {
- case "m.room.member", "m.room.name", "m.room.topic", "m.room.aliases", "m.room.canonical_alias":
- return true
- default:
- return false
- }
-}
-
func (s *GomuksSyncer) processSyncEvent(room *rooms.Room, event *gomatrix.Event, source EventSource) {
if room != nil {
event.RoomID = room.ID
}
- if isState(event) {
+ if event.Type.Class == gomatrix.StateEventType {
room.UpdateState(event)
}
s.notifyListeners(source, event)
@@ -135,7 +126,7 @@ func (s *GomuksSyncer) processSyncEvent(room *rooms.Room, event *gomatrix.Event,
// OnEventType allows callers to be notified when there are new events for the given event type.
// There are no duplicate checks.
-func (s *GomuksSyncer) OnEventType(eventType string, callback EventHandler) {
+func (s *GomuksSyncer) OnEventType(eventType gomatrix.EventType, callback EventHandler) {
_, exists := s.listeners[eventType]
if !exists {
s.listeners[eventType] = []EventHandler{}