Browse Source
Perform a sync request with full state when starting
Signed-off-by: Nikos Filippakis <me@nfil.dev>
pull/324/head
Nikos Filippakis
5 years ago
No known key found for this signature in database
GPG Key ID: 7110E4356101F017
2 changed files with
10 additions and
1 deletions
-
clients/clients.go
-
goneb.go
|
|
@ -362,6 +362,7 @@ func (c *Clients) initClient(botClient *BotClient) error { |
|
|
|
return err |
|
|
|
} |
|
|
|
|
|
|
|
// Register sync callback for maintaining the state store and Olm machine state
|
|
|
|
botClient.Register(syncer) |
|
|
|
|
|
|
|
syncer.OnEventType(mevt.EventMessage, func(_ mautrix.EventSource, event *mevt.Event) { |
|
|
@ -426,6 +427,14 @@ func (c *Clients) initClient(botClient *BotClient) error { |
|
|
|
|
|
|
|
if config.Sync { |
|
|
|
go func() { |
|
|
|
// Get the state store up to date
|
|
|
|
resp, err := botClient.SyncRequest(30000, "", "", true, mevt.PresenceOnline) |
|
|
|
if err != nil { |
|
|
|
log.WithError(err).Error("Error performing initial sync") |
|
|
|
return |
|
|
|
} |
|
|
|
botClient.stateStore.UpdateStateStore(resp) |
|
|
|
|
|
|
|
for { |
|
|
|
if e := client.Sync(); e != nil { |
|
|
|
log.WithFields(log.Fields{ |
|
|
|
|
|
@ -139,7 +139,7 @@ func insertServicesFromConfig(clis *clients.Clients, serviceReqs []api.Configure |
|
|
|
} |
|
|
|
|
|
|
|
func loadDatabase(databaseType, databaseURL, configYAML string) (*database.ServiceDB, error) { |
|
|
|
if configYAML != "" { |
|
|
|
if databaseType == "" && databaseURL == "" { |
|
|
|
databaseType = "sqlite3" |
|
|
|
databaseURL = ":memory:?_busy_timeout=5000" |
|
|
|
} |
|
|
|