From 3460d7b6e861950275c63076dcc7af007426e179 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 25 Jun 2020 17:59:44 +0300 Subject: [PATCH] Make WhatsApp device name configurable --- config/config.go | 7 +++++++ example-config.yaml | 5 +++++ user.go | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index af28cd3..8abb8ba 100644 --- a/config/config.go +++ b/config/config.go @@ -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() } diff --git a/example-config.yaml b/example-config.yaml index f19dea5..062282d 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -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. diff --git a/user.go b/user.go index 969cc55..f5d770c 100644 --- a/user.go +++ b/user.go @@ -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()