Make WhatsApp device name configurable

This commit is contained in:
Tulir Asokan 2020-06-25 17:59:44 +03:00
parent d0ccc85522
commit 3460d7b6e8
3 changed files with 13 additions and 1 deletions

View file

@ -66,6 +66,11 @@ type Config struct {
Listen string `yaml:"listen"`
} `yaml:"metrics"`
WhatsApp struct {
DeviceName string `yaml:"device_name"`
ShortName string `yaml:"short_name"`
} `yaml:"whatsapp"`
Bridge BridgeConfig `yaml:"bridge"`
Logging appservice.LogConfig `yaml:"logging"`
@ -74,6 +79,8 @@ type Config struct {
func (config *Config) setDefaults() {
config.AppService.Database.MaxOpenConns = 20
config.AppService.Database.MaxIdleConns = 2
config.WhatsApp.DeviceName = "Mautrix-WhatsApp bridge"
config.WhatsApp.ShortName = "mx-wa"
config.Bridge.setDefaults()
}

View file

@ -55,6 +55,11 @@ metrics:
# IP and port where the metrics listener should be. The path is always /metrics
listen: 127.0.0.1:8001
whatsapp:
# Device name that's shown in the "WhatsApp Web" section in the mobile app
device_name: Mautrix-WhatsApp bridge
short_name: mx-wa
# Bridge config
bridge:
# Localpart template of MXIDs for WhatsApp users.

View file

@ -236,7 +236,7 @@ func (user *User) Connect(evenIfNoSession bool) bool {
return false
}
user.Conn = whatsappExt.ExtendConn(conn)
_ = user.Conn.SetClientName("Mautrix-WhatsApp bridge", "mx-wa", WAVersion)
_ = user.Conn.SetClientName(user.bridge.Config.WhatsApp.DeviceName, user.bridge.Config.WhatsApp.ShortName, WAVersion)
user.log.Debugln("WhatsApp connection successful")
user.Conn.AddHandler(user)
return user.RestoreSession()