M cmd/tallyard/main.go => cmd/tallyard/main.go +2 -1
@@ 52,6 52,8 @@ func main() {
}
client, err := mautrix.NewClient(authInfo.Homeserver, authInfo.UserID, authInfo.AccessToken)
+ syncer := NewTallyardSyncer()
+ client.Syncer = syncer
client.Logger = TallyardLogger{}
if err != nil {
log.Panic(err)
@@ 67,7 69,6 @@ func main() {
client.Store = matrix.NewTallyardStore(electionsMap)
defer electionsMap.Save()
- syncer := client.Syncer.(*mautrix.DefaultSyncer)
syncer.OnEvent(debugEventHook)
syncer.OnEvent(client.Store.(*matrix.TallyardStore).UpdateState)
electionsMap.SetupEventHooks(client, syncer)
M cmd/tallyard/syncer.go => cmd/tallyard/syncer.go +16 -0
@@ 5,6 5,7 @@ import (
log "github.com/sirupsen/logrus"
"maunium.net/go/mautrix"
+ "maunium.net/go/mautrix/event"
)
type TallyardSyncer struct {
@@ 16,3 17,18 @@ func (s *TallyardSyncer) OnFailedSync(res *mautrix.RespSync, err error) (time.Du
log.Warnf("encountered sync error; retrying in %s: %s", sleepDuration, err)
return sleepDuration, nil
}
+
+func NewTallyardSyncer() *TallyardSyncer {
+ t := &TallyardSyncer{
+ mautrix.NewDefaultSyncer(),
+ }
+ t.ParseErrorHandler = func(evt *event.Event, err error) bool {
+ if evt == nil {
+ log.Debugf("a parse error occurred for nil event: %s", err)
+ } else {
+ log.Debugf("a parse error occurred for event %s: %s", evt.ID, err)
+ }
+ return false
+ }
+ return t
+}