diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-21 23:29:58 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-21 23:29:58 +0200 |
commit | 9fd67102ad2cca16c092e23ffd928b77ab08d7e0 (patch) | |
tree | 2c34025e564806cb8f9faad0c15e25a0e6dec3ed /matrix/sync.go | |
parent | b4902d4edb27baf59b21747117d93db4e0e4e96c (diff) |
Refactoring and godocs
Diffstat (limited to 'matrix/sync.go')
-rw-r--r-- | matrix/sync.go | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/matrix/sync.go b/matrix/sync.go index 9eeb87a..a5f3b91 100644 --- a/matrix/sync.go +++ b/matrix/sync.go @@ -1,3 +1,21 @@ +// gomuks - A terminal Matrix client written in Go. +// Copyright (C) 2018 Tulir Asokan +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. + +// Based on https://github.com/matrix-org/gomatrix/blob/master/sync.go + package matrix import ( @@ -26,15 +44,16 @@ func NewGomuksSyncer(session *config.Session) *GomuksSyncer { } } +// ProcessResponse processes a Matrix sync response. func (s *GomuksSyncer) ProcessResponse(res *gomatrix.RespSync, since string) (err error) { - if !s.shouldProcessResponse(res, since) { + if len(since) == 0 { return } // gdebug.Print("Processing sync response", since, res) defer func() { if r := recover(); r != nil { - err = fmt.Errorf("ProcessResponse panicked! userID=%s since=%s panic=%s\n%s", s.Session.MXID, since, r, debug.Stack()) + err = fmt.Errorf("ProcessResponse panicked! userID=%s since=%s panic=%s\n%s", s.Session.UserID, since, r, debug.Stack()) } }() @@ -99,15 +118,6 @@ func (s *GomuksSyncer) OnEventType(eventType string, callback gomatrix.OnEventLi s.listeners[eventType] = append(s.listeners[eventType], callback) } -// shouldProcessResponse returns true if the response should be processed. May modify the response to remove -// stuff that shouldn't be processed. -func (s *GomuksSyncer) shouldProcessResponse(resp *gomatrix.RespSync, since string) bool { - if since == "" { - return false - } - return true -} - func (s *GomuksSyncer) notifyListeners(event *gomatrix.Event) { listeners, exists := s.listeners[event.Type] if !exists { |