mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-13 17:13:11 +01:00
Make connection timeout configurable
This commit is contained in:
parent
5d0edda04a
commit
b5af35684d
2 changed files with 7 additions and 1 deletions
|
@ -33,6 +33,8 @@ type BridgeConfig struct {
|
||||||
UsernameTemplate string `yaml:"username_template"`
|
UsernameTemplate string `yaml:"username_template"`
|
||||||
DisplaynameTemplate string `yaml:"displayname_template"`
|
DisplaynameTemplate string `yaml:"displayname_template"`
|
||||||
|
|
||||||
|
ConnectionTimeout int `yaml:"connection_timeout"`
|
||||||
|
|
||||||
CommandPrefix string `yaml:"command_prefix"`
|
CommandPrefix string `yaml:"command_prefix"`
|
||||||
|
|
||||||
Permissions PermissionConfig `yaml:"permissions"`
|
Permissions PermissionConfig `yaml:"permissions"`
|
||||||
|
|
6
user.go
6
user.go
|
@ -145,7 +145,11 @@ func (user *User) Connect(evenIfNoSession bool) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
user.log.Debugln("Connecting to WhatsApp")
|
user.log.Debugln("Connecting to WhatsApp")
|
||||||
conn, err := whatsapp.NewConn(20 * time.Second)
|
timeout := time.Duration(user.bridge.Config.Bridge.ConnectionTimeout)
|
||||||
|
if timeout == 0 {
|
||||||
|
timeout = 20
|
||||||
|
}
|
||||||
|
conn, err := whatsapp.NewConn(timeout * time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
user.log.Errorln("Failed to connect to WhatsApp:", err)
|
user.log.Errorln("Failed to connect to WhatsApp:", err)
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue