From fcd9a932cb5542ed8980fc1daba7ee1f0041a3f2 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 02:11:32 +0300 Subject: Initial move to initial sync. Everything broke :( --- matrix/sync.go | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'matrix/sync.go') diff --git a/matrix/sync.go b/matrix/sync.go index f3966cb..ec1c34e 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -20,16 +20,16 @@ package matrix import ( "encoding/json" - "fmt" - "runtime/debug" "time" "maunium.net/go/gomatrix" + "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/matrix/rooms" ) type SyncerSession interface { GetRoom(id string) *rooms.Room + SetInitialSyncDone() GetUserID() string } @@ -53,16 +53,7 @@ func NewGomuksSyncer(session SyncerSession) *GomuksSyncer { // ProcessResponse processes a Matrix sync response. func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (err error) { - if len(since) == 0 { - return - } - // debug.Print("Processing sync response", since, res) - - defer func() { - if r := recover(); r != nil { - err = fmt.Errorf("ProcessResponse for %s since %s panicked: %s\n%s", s.Session.GetUserID(), since, r, debug.Stack()) - } - }() + debug.Print("Processing sync response", since, res) s.processSyncEvents(nil, res.Presence.Events, false, false) s.processSyncEvents(nil, res.AccountData.Events, false, false) @@ -93,6 +84,9 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er } } + if since == "" { + s.Session.SetInitialSyncDone() + } s.FirstSyncDone = true return -- cgit v1.2.3 From e64df67ec397795b8c6ebd06b391d953afe5a766 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 16:51:40 +0300 Subject: Everything is no longer broken --- matrix/sync.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'matrix/sync.go') diff --git a/matrix/sync.go b/matrix/sync.go index ec1c34e..d0e1e69 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -23,7 +23,6 @@ import ( "time" "maunium.net/go/gomatrix" - "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/matrix/rooms" ) @@ -53,8 +52,6 @@ func NewGomuksSyncer(session SyncerSession) *GomuksSyncer { // ProcessResponse processes a Matrix sync response. func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (err error) { - debug.Print("Processing sync response", since, res) - s.processSyncEvents(nil, res.Presence.Events, false, false) s.processSyncEvents(nil, res.AccountData.Events, false, false) @@ -141,7 +138,13 @@ func (s *GomuksSyncer) GetFilterJSON(userID string) json.RawMessage { "room": { "include_leave": true, "state": { - "types": ["m.room.member"] + "types": [ + "m.room.member", + "m.room.name", + "m.room.topic", + "m.room.canonical_alias", + "m.room.aliases" + ] }, "timeline": { "types": ["m.room.message"], -- cgit v1.2.3 From 28c65275440b3f7371540b49733db8b6b170a64d Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 24 Apr 2018 17:12:08 +0300 Subject: Fix/break/change things --- matrix/sync.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'matrix/sync.go') diff --git a/matrix/sync.go b/matrix/sync.go index d0e1e69..8ad7ad5 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -28,7 +28,6 @@ import ( type SyncerSession interface { GetRoom(id string) *rooms.Room - SetInitialSyncDone() GetUserID() string } @@ -36,9 +35,10 @@ type SyncerSession interface { // replace parts of this default syncer (e.g. the ProcessResponse method). The default syncer uses the observer // pattern to notify callers about incoming events. See GomuksSyncer.OnEventType for more information. type GomuksSyncer struct { - Session SyncerSession - listeners map[string][]gomatrix.OnEventListener // event type to listeners array - FirstSyncDone bool + Session SyncerSession + listeners map[string][]gomatrix.OnEventListener // event type to listeners array + FirstSyncDone bool + InitDoneCallback func() } // NewGomuksSyncer returns an instantiated GomuksSyncer @@ -81,8 +81,8 @@ func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (er } } - if since == "" { - s.Session.SetInitialSyncDone() + if since == "" && s.InitDoneCallback != nil { + s.InitDoneCallback() } s.FirstSyncDone = true -- cgit v1.2.3