Add option to maybe detect xml-not-well-formed errors

This commit is contained in:
Tulir Asokan 2022-04-25 17:21:43 +03:00
parent 30fd0d7c85
commit ea3bcec1cf
6 changed files with 9 additions and 3 deletions

View file

@ -73,6 +73,8 @@ type Config struct {
WhatsApp struct { WhatsApp struct {
OSName string `yaml:"os_name"` OSName string `yaml:"os_name"`
BrowserName string `yaml:"browser_name"` BrowserName string `yaml:"browser_name"`
DebugDecodeBeforeSend bool `yaml:"debug_decode_before_send"`
} `yaml:"whatsapp"` } `yaml:"whatsapp"`
Bridge BridgeConfig `yaml:"bridge"` Bridge BridgeConfig `yaml:"bridge"`

View file

@ -69,6 +69,7 @@ func (helper *UpgradeHelper) doUpgrade() {
helper.Copy(Str, "whatsapp", "os_name") helper.Copy(Str, "whatsapp", "os_name")
helper.Copy(Str, "whatsapp", "browser_name") helper.Copy(Str, "whatsapp", "browser_name")
helper.Copy(Bool, "whatsapp", "debug_decode_before_send")
helper.Copy(Str, "bridge", "username_template") helper.Copy(Str, "bridge", "username_template")
helper.Copy(Str, "bridge", "displayname_template") helper.Copy(Str, "bridge", "displayname_template")

View file

@ -91,6 +91,8 @@ whatsapp:
# Must be "unknown" for a generic icon or a valid browser name if you want a specific icon. # Must be "unknown" for a generic icon or a valid browser name if you want a specific icon.
# List of valid browser names: https://github.com/tulir/whatsmeow/blob/8b34d886d543b72e5f4699cf5b2797f68d598f78/binary/proto/def.proto#L38-L51 # List of valid browser names: https://github.com/tulir/whatsmeow/blob/8b34d886d543b72e5f4699cf5b2797f68d598f78/binary/proto/def.proto#L38-L51
browser_name: unknown browser_name: unknown
# Decode outgoing binary XML payloads to try to make sure they're valid before sending to WhatsApp.
debug_decode_before_send: false
# Bridge config # Bridge config
bridge: bridge:

2
go.mod
View file

@ -10,7 +10,7 @@ require (
github.com/prometheus/client_golang v1.11.1 github.com/prometheus/client_golang v1.11.1
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/tidwall/gjson v1.14.0 github.com/tidwall/gjson v1.14.0
go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9 go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 golang.org/x/net v0.0.0-20220412020605-290c469a71a5
google.golang.org/protobuf v1.28.0 google.golang.org/protobuf v1.28.0

4
go.sum
View file

@ -120,8 +120,8 @@ github.com/yuin/goldmark v1.4.11 h1:i45YIzqLnUc2tGaTlJCyUxSG8TvgyGqhqOZOUKIjJ6w=
github.com/yuin/goldmark v1.4.11/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= github.com/yuin/goldmark v1.4.11/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg=
go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0 h1:3IQF2bgAyibdo77hTejwuJe4jlypj9QaE4xCQuxrThM= go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0 h1:3IQF2bgAyibdo77hTejwuJe4jlypj9QaE4xCQuxrThM=
go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0/go.mod h1:kBOXTvYyDG/q1Ihgvd4J6WenGPh7wtEGvPKF6vmf5ak= go.mau.fi/libsignal v0.0.0-20220425070825-c40c839ee6a0/go.mod h1:kBOXTvYyDG/q1Ihgvd4J6WenGPh7wtEGvPKF6vmf5ak=
go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9 h1:qvADKrQ2RzizRJh4R39h6bHedKCbOrI38JuGE+Ec6xI= go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742 h1:0DFoHvUhQJf+X8pzgXFvCaEfv/nxO0yb2fn5JpCovjY=
go.mau.fi/whatsmeow v0.0.0-20220425070941-bf3901f10cd9/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c= go.mau.fi/whatsmeow v0.0.0-20220425142103-46b439456742/go.mod h1:iUBgOLNaqShLrR17u0kIiRptIGFH+nbT1tRhaWBEX/c=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

View file

@ -333,6 +333,7 @@ var ErrAlreadyLoggedIn = errors.New("already logged in")
func (user *User) createClient(sess *store.Device) { func (user *User) createClient(sess *store.Device) {
user.Client = whatsmeow.NewClient(sess, &waLogger{user.log.Sub("Client")}) user.Client = whatsmeow.NewClient(sess, &waLogger{user.log.Sub("Client")})
user.Client.DebugDecodeBeforeSend = user.bridge.Config.WhatsApp.DebugDecodeBeforeSend
user.Client.AddEventHandler(user.HandleEvent) user.Client.AddEventHandler(user.HandleEvent)
user.Client.SetForceActiveDeliveryReceipts(user.bridge.Config.Bridge.ForceActiveDeliveryReceipts) user.Client.SetForceActiveDeliveryReceipts(user.bridge.Config.Bridge.ForceActiveDeliveryReceipts)
user.Client.GetMessageForRetry = func(to types.JID, id types.MessageID) *waProto.Message { user.Client.GetMessageForRetry = func(to types.JID, id types.MessageID) *waProto.Message {