Make contact wait delay configurable and fix nil pointer usage
This commit is contained in:
parent
02f78155b5
commit
37cd34e4bf
4 changed files with 10 additions and 4 deletions
|
@ -37,6 +37,7 @@ type BridgeConfig struct {
|
|||
MaxConnectionAttempts int `yaml:"max_connection_attempts"`
|
||||
ConnectionRetryDelay int `yaml:"connection_retry_delay"`
|
||||
ReportConnectionRetry bool `yaml:"report_connection_retry"`
|
||||
ContactWaitDelay int `yaml:"contact_wait_delay"`
|
||||
|
||||
InitialChatSync int `yaml:"initial_chat_sync_count"`
|
||||
InitialHistoryFill int `yaml:"initial_history_fill_count"`
|
||||
|
@ -59,6 +60,7 @@ func (bc *BridgeConfig) setDefaults() {
|
|||
bc.MaxConnectionAttempts = 3
|
||||
bc.ConnectionRetryDelay = -1
|
||||
bc.ReportConnectionRetry = true
|
||||
bc.ContactWaitDelay = 1
|
||||
|
||||
bc.InitialChatSync = 10
|
||||
bc.InitialHistoryFill = 20
|
||||
|
|
|
@ -68,6 +68,9 @@ bridge:
|
|||
# Whether or not the bridge should send a notice to the user's management room when it retries connecting.
|
||||
# If false, it will only report when it stops retrying.
|
||||
report_connection_retry: true
|
||||
# Number of seconds to wait for contacts and chats to be sent at startup before syncing.
|
||||
# If you have lots of chats, it might take more than a second.
|
||||
contact_wait_delay: 1
|
||||
|
||||
# Number of chats to sync for new users.
|
||||
initial_chat_sync_count: 10
|
||||
|
|
|
@ -410,7 +410,7 @@ func (portal *Portal) ensureUserInvited(user *User) {
|
|||
portal.log.Warnfln("Failed to ensure %s is invited to %s: %v", user.MXID, portal.MXID, err)
|
||||
}
|
||||
customPuppet := portal.bridge.GetPuppetByCustomMXID(user.MXID)
|
||||
if customPuppet.CustomIntent() != nil {
|
||||
if customPuppet != nil && customPuppet.CustomIntent() != nil {
|
||||
_ = customPuppet.CustomIntent().EnsureJoined(portal.MXID)
|
||||
}
|
||||
}
|
||||
|
|
7
user.go
7
user.go
|
@ -296,10 +296,11 @@ func (user *User) PostLogin() {
|
|||
}
|
||||
|
||||
func (user *User) intPostLogin() {
|
||||
user.log.Debugln("Waiting a second for contacts to arrive")
|
||||
dur := time.Duration(user.bridge.Config.Bridge.ContactWaitDelay) * time.Second
|
||||
user.log.Debugfln("Waiting %s for contacts to arrive", dur)
|
||||
// Hacky way to wait for chats and contacts to arrive automatically
|
||||
time.Sleep(1 * time.Second)
|
||||
user.log.Debugln("Waited a second, have", len(user.Conn.Store.Chats), "chats and", len(user.Conn.Store.Contacts), "contacts")
|
||||
time.Sleep(dur)
|
||||
user.log.Debugfln("Waited %s, have %d chats and %d contacts", dur, len(user.Conn.Store.Chats), len(user.Conn.Store.Contacts))
|
||||
|
||||
go user.syncPuppets()
|
||||
user.syncPortals(false)
|
||||
|
|
Loading…
Reference in a new issue